infra: add Docker, Compose, and Nginx for staging deployment
- Dockerfile: multi-stage build (deps → builder → runner), standalone output - docker-compose.yml: app + postgres services, health checks - nginx/staging.letsbe.biz.conf: reverse proxy ready for certbot SSL - Updated .env.example with all required secrets Deploy steps: 1. Copy nginx conf to /etc/nginx/sites-enabled/ 2. nginx -t && systemctl reload nginx 3. certbot --nginx -d staging.letsbe.biz 4. Create .env from .env.example 5. docker compose up -d --build Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
49
Dockerfile
Normal file
49
Dockerfile
Normal file
@@ -0,0 +1,49 @@
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
# ── Dependencies ──
|
||||
FROM base AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --ignore-scripts
|
||||
RUN npm rebuild sharp
|
||||
|
||||
# ── Builder ──
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Build args become env vars at build time
|
||||
ARG DATABASE_URI
|
||||
ARG PAYLOAD_SECRET
|
||||
ARG NEXT_PUBLIC_SITE_URL
|
||||
ARG NEXT_PUBLIC_CALCOM_URL
|
||||
|
||||
ENV DATABASE_URI=${DATABASE_URI}
|
||||
ENV PAYLOAD_SECRET=${PAYLOAD_SECRET}
|
||||
ENV NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL}
|
||||
ENV NEXT_PUBLIC_CALCOM_URL=${NEXT_PUBLIC_CALCOM_URL}
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ── Runner ──
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
# Copy standalone output
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user