saas_app/Dockerfile
2025-12-09 15:45:32 -03:00

42 lines
909 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
# ============================
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
ENV NODE_ENV=production
RUN npm run build
# ============================
# STAGE 2 Runner (standalone)
# ============================
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Copia apenas o necessário do build
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
# Corrige permissões (para cache de imagens, etc.)
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs \
&& mkdir -p .next/cache/images \
&& chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 3000
# Executa o servidor standalone gerado pelo Next
CMD ["node", "server.js"]