chore(docker): update Dockerfile for Next 16, drop duplicate lowercase dockerfile
- update stage comments to Next 16; note Turbopack default build - npm ci --no-audit --no-fund for faster reproducible install - add HEALTHCHECK (referenced by docker-compose, previously missing) - parametrize node version via ARG NODE_VERSION - remove duplicate case-variant 'dockerfile' (collided with 'Dockerfile' on case-insensitive FS, would be two files on Linux/Coolify) Verified: docker build + run, all routes 200, multi-domain Host routing, canonical in <head>, container healthcheck reports healthy. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+17
-6
@@ -1,12 +1,15 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Multi-stage Dockerfile for Next.js 15 (App Router, output: 'standalone')
|
||||
# Multi-stage Dockerfile for Next.js 16 (App Router, output: 'standalone').
|
||||
# Based on the official Next.js Docker example, tuned for Coolify.
|
||||
# Reference: https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
|
||||
# References:
|
||||
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
|
||||
# https://coolify.io/docs/applications/nextjs
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Base image
|
||||
# ----------------------------------------------------------------------------
|
||||
FROM node:22-alpine AS base
|
||||
ARG NODE_VERSION=22
|
||||
FROM node:${NODE_VERSION}-alpine AS base
|
||||
# libc6-compat is recommended by the Next.js image for some native deps (sharp, etc.)
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
@@ -17,14 +20,16 @@ WORKDIR /app
|
||||
# ----------------------------------------------------------------------------
|
||||
FROM base AS deps
|
||||
COPY package.json package-lock.json .npmrc ./
|
||||
# Reproducible install honouring the lockfile (.npmrc provides legacy-peer-deps).
|
||||
RUN npm ci
|
||||
# Reproducible install honouring the lockfile (.npmrc provides legacy-peer-deps,
|
||||
# required because react-google-map-picker declares a React 17 peer).
|
||||
RUN npm ci --no-audit --no-fund
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# 2. Builder — produces the standalone output.
|
||||
# NEXT_PUBLIC_* values are inlined into the client bundle at BUILD time,
|
||||
# so they must be passed as build args. DEV_MODE is read in app/layout.js
|
||||
# to enable Google Analytics, so it must also be present at build time.
|
||||
# to toggle Google Analytics + robots noindex, so it must also be present
|
||||
# at build time.
|
||||
# ----------------------------------------------------------------------------
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
@@ -46,6 +51,8 @@ ENV NODE_ENV=production
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Next 16 builds with Turbopack by default; output: 'standalone' emits
|
||||
# .next/standalone/server.js plus a trimmed node_modules.
|
||||
RUN npm run build
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -76,5 +83,9 @@ USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Container-level health probe (also referenced by docker-compose / Coolify).
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD node -e "require('http').get('http://127.0.0.1:3000/',r=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))"
|
||||
|
||||
# server.js is generated by Next.js at the root of the standalone output.
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
Reference in New Issue
Block a user