All checks were successful
Build & Push / build-and-push (push) Successful in 1m55s
The nextjs user couldn't write to .next/cache at runtime because the directory was created by root during the build stage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.1 KiB
Docker
53 lines
1.1 KiB
Docker
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
|
|
|
|
# Ensure .next/cache is writable by the nextjs user
|
|
RUN mkdir -p .next/cache && chown -R nextjs:nodejs .next
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "server.js"]
|