You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB
Docker

# syntax=docker/dockerfile:1
# ── Stage 1: build (Node) ───────────────────────────────────────────────────
# Compila o site Vite. Corre `tsc -b` (gate de TypeScript) + `vite build`.
FROM node:22-alpine AS build
WORKDIR /app
# Instala dependências primeiro (camada cacheável).
COPY package.json package-lock.json* ./
RUN npm ci || npm install
# Copia o resto do código e gera o build estático.
COPY . .
RUN npm run build
# ── Stage 2: runtime (nginx) ────────────────────────────────────────────────
# Imagem final isolada: serve `dist/` estático. Sem Node nem código-fonte.
FROM nginx:1.27-alpine AS runtime
# Config nginx (SPA fallback + gzip + cache de assets).
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Conteúdo estático compilado.
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
# Healthcheck simples (página inicial responde 200).
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q --spider http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"]