Skip to content

Commit a976815

Browse files
authored
Yes
1 parent 761f3a2 commit a976815

2 files changed

Lines changed: 7 additions & 64 deletions

File tree

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ WORKDIR /app
1010
COPY --from=deps /app/node_modules ./node_modules
1111
COPY . .
1212
ENV NEXT_TELEMETRY_DISABLED=1
13+
# Dummy DATABASE_URL to pass build time checks
1314
ENV DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy"
1415
RUN npm run build
1516

@@ -21,12 +22,13 @@ CMD ["npm", "run", "db:push"]
2122

2223
FROM node:20-slim AS runner
2324
WORKDIR /app
24-
ENV DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy"
2525
ENV NODE_ENV=production
2626
ENV NEXT_TELEMETRY_DISABLED=1
2727
ENV PORT=3000
2828
ENV HOSTNAME=0.0.0.0
2929

30+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
31+
3032
RUN groupadd --system --gid 1001 nodejs \
3133
&& useradd --system --uid 1001 --gid 1001 --create-home nextjs
3234

@@ -35,4 +37,5 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
3537
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
3638

3739
USER nextjs
38-
CMD ["node", "server.js"]
40+
EXPOSE 3000
41+
CMD ["node", "server.js"]

docker-compose.yml

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,74 +13,14 @@ services:
1313
- .env
1414
environment:
1515
NODE_ENV: production
16-
17-
DATABASE_URL: postgres://postgres:postgres@postgres:5432/photos
18-
REDIS_URL: redis://dragonfly:6379
19-
NEXTAUTH_URL: https://photos.hackclub.com
20-
2116
depends_on:
22-
postgres:
23-
condition: service_healthy
24-
dragonfly:
25-
condition: service_started
2617
migrate:
2718
condition: service_completed_successfully
2819

29-
# (Removed resource limits to prioritize raw throughput)
30-
3120
migrate:
3221
build:
3322
context: .
3423
dockerfile: Dockerfile
3524
target: migration
36-
environment:
37-
DATABASE_URL: postgres://postgres:postgres@postgres:5432/photos
38-
depends_on:
39-
postgres:
40-
condition: service_healthy
41-
42-
postgres:
43-
image: postgres:16-alpine
44-
container_name: hack-club-photos-postgres
45-
restart: unless-stopped
46-
environment:
47-
POSTGRES_USER: postgres
48-
POSTGRES_PASSWORD: postgres
49-
POSTGRES_DB: photos
50-
volumes:
51-
- postgres_data:/var/lib/postgresql/data
52-
healthcheck:
53-
test: ["CMD-SHELL", "pg_isready -U postgres -d photos -h 127.0.0.1"]
54-
interval: 10s
55-
timeout: 5s
56-
retries: 5
57-
58-
# Small/medium deployment tuning (adjust to your machine)
59-
command:
60-
- "postgres"
61-
- "-c"
62-
- "shared_buffers=256MB"
63-
- "-c"
64-
- "effective_cache_size=768MB"
65-
- "-c"
66-
- "work_mem=16MB"
67-
- "-c"
68-
- "maintenance_work_mem=128MB"
69-
- "-c"
70-
- "max_connections=200"
71-
72-
# (Removed log rotation limits to keep config minimal; add back if disk logs become an issue)
73-
74-
dragonfly:
75-
image: docker.dragonflydb.io/dragonflydb/dragonfly
76-
container_name: hack-club-photos-dragonfly
77-
restart: unless-stopped
78-
# Prioritize speed: allow Dragonfly to use available RAM and avoid snapshot overhead.
79-
# If you want durability, re-add --save_schedule and/or AOF-like persistence.
80-
command: ["--maxmemory=0"]
81-
volumes:
82-
- dragonfly_data:/data
83-
84-
volumes:
85-
postgres_data:
86-
dragonfly_data:
25+
env_file:
26+
- .env

0 commit comments

Comments
 (0)