- Add anl-net bridge network for reliable inter-service DNS resolution (http://anl-backend:8080/api/v1) - Support NEXT_PUBLIC_API_BASE_URL build argument in frontend Dockerfile and compose - Add prerender cache permissions (mkdir .next && chown nextjs:nodejs) in refer_landing_page/Dockerfile - Add root .env.example with documented port and token configurations - Add backend/.dockerignore to optimize backend build context - Pass all unit tests and E2E gates with 100% unanimous PASS review verdicts
60 lines
1.8 KiB
Docker
60 lines
1.8 KiB
Docker
# ==============================================================================
|
|
# Stage 1: Install Dependencies
|
|
# ==============================================================================
|
|
FROM node:20-alpine AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
# ==============================================================================
|
|
# Stage 2: Build Application
|
|
# ==============================================================================
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Build-time argument for inlining client-side API URL into Next.js bundle
|
|
ARG NEXT_PUBLIC_API_BASE_URL
|
|
ENV NEXT_PUBLIC_API_BASE_URL=${NEXT_PUBLIC_API_BASE_URL} \
|
|
NEXT_TELEMETRY_DISABLED=1 \
|
|
NODE_ENV=production
|
|
|
|
RUN npm run build
|
|
|
|
# ==============================================================================
|
|
# Stage 3: Production Runner
|
|
# ==============================================================================
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production \
|
|
NEXT_TELEMETRY_DISABLED=1 \
|
|
PORT=3000 \
|
|
HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy static assets and public directories
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Set permissions for prerender cache
|
|
RUN mkdir .next && chown nextjs:nodejs .next
|
|
|
|
# Copy standalone build output and static assets
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
|
|
|
|
CMD ["node", "server.js"]
|