Skip to content

Instantly share code, notes, and snippets.

@hmaesta
Last active January 6, 2026 17:59
Show Gist options
  • Select an option

  • Save hmaesta/b43737bd40d419767c1d8f5632fb6de8 to your computer and use it in GitHub Desktop.

Select an option

Save hmaesta/b43737bd40d419767c1d8f5632fb6de8 to your computer and use it in GitHub Desktop.
Next 16 experiment - minimal Dockerfile
# syntax=docker.io/docker/dockerfile:1
FROM node:25.2.1-alpine AS base
# Dependencies
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json package-lock.json*.npmrc* ./
RUN npm install
# Source code
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# Production image
FROM base AS runner
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1 \
NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment