Snippets / Dockerfile
Static site (build + nginx)
Builds a frontend (Vite/React/etc.) and serves the static output with nginx.
nginxstaticfrontendmulti-stage
Dockerfile
# --- build ---
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
# --- serve ---
# Final image never installs Node at all -- just nginx and the static
# files the build stage produced.
FROM nginx:1.27-alpine
COPY /app/dist /usr/share/nginx/html
# nginx.conf comes from your own repo, not the build stage -- this is
# where you'd add e.g. a try_files fallback for client-side routing.
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
More dockerfile snippets