saas_app/Dockerfile
2025-12-09 15:19:43 -03:00

43 lines
958 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================
# STAGE 1 Build da aplicação
# ============================
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# Garante build de produção
ENV NODE_ENV=production
RUN npm run build
# =============================
# STAGE 2 Produção (Runner)
# =============================
FROM node:20-alpine AS runner
WORKDIR /app
# Força modo produção
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Copia somente o necessário
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/next.config.* ./
COPY --from=builder /app/node_modules ./node_modules
# Segurança: executa como usuário não-root
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs
USER nextjs
# Porta padrão
EXPOSE 3000
# Comando fixo (força produção)
CMD ["sh", "-c", "NODE_ENV=production npm start"]