mirror of
https://github.com/runyanjake/cooking.git
synced 2026-06-25 08:04:51 -07:00
39 lines
1.0 KiB
Docker
39 lines
1.0 KiB
Docker
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
# Lint + type-check target, used by CI (docker build --target ci).
|
|
FROM deps AS ci
|
|
COPY . .
|
|
RUN npm run lint && npx tsc --noEmit
|
|
|
|
FROM node:20-alpine AS build
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
FROM node:20-alpine 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 --from=build /app/public ./public
|
|
COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
|
|
# Liveness probe against the dedicated /healthz route. Use 127.0.0.1 (not
|
|
# localhost) so busybox wget hits the IPv4 address the server binds to.
|
|
HEALTHCHECK --interval=5s --timeout=3s --start-period=15s --retries=3 \
|
|
CMD wget -q -O /dev/null http://127.0.0.1:3000/healthz || exit 1
|
|
|
|
CMD ["node", "server.js"]
|