46 lines
1.3 KiB
Docker
46 lines
1.3 KiB
Docker
# =============================================================================
|
|
# STAGE 1: Build da aplicação React/Vite
|
|
# =============================================================================
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache python3 make g++ git
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install ALL dependencies (including devDependencies for build)
|
|
RUN npm ci && npm cache clean --force
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build para produção
|
|
RUN npm run build
|
|
|
|
# =============================================================================
|
|
# STAGE 2: Servir com Nginx
|
|
# =============================================================================
|
|
FROM nginx:alpine
|
|
|
|
# Remover configuração padrão do Nginx
|
|
RUN rm -rf /usr/share/nginx/html/* /etc/nginx/conf.d/default.conf
|
|
|
|
# Copiar build do stage anterior
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Copiar configuração customizada do Nginx
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Expor porta 3737 (mantendo compatibilidade com a config atual)
|
|
EXPOSE 3737
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3737/ || exit 1
|
|
|
|
# Iniciar Nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|