Atualizar Dockerfile
This commit is contained in:
41
Dockerfile
41
Dockerfile
@@ -1,30 +1,41 @@
|
||||
# Etapa 1 - Build da aplicação Vite
|
||||
FROM node:18 AS build
|
||||
# =========================
|
||||
# Etapa 1 - Build Vite
|
||||
# =========================
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
# Diretório de trabalho
|
||||
WORKDIR /app
|
||||
|
||||
# Copiar o ZIP para dentro do container
|
||||
# Instalar unzip
|
||||
RUN apk add --no-cache unzip
|
||||
|
||||
# Copiar o ZIP
|
||||
COPY app.zip .
|
||||
|
||||
# Instalar unzip e extrair diretamente em /app
|
||||
RUN apt-get update && apt-get install -y unzip && \
|
||||
unzip app.zip -d . && \
|
||||
rm app.zip
|
||||
# Descompactar conteúdo diretamente em /app
|
||||
RUN unzip app.zip -d . && rm app.zip
|
||||
|
||||
# (opcional para debug: ver se o package.json está aqui)
|
||||
# RUN ls -la && ls -la src
|
||||
# (DEBUG OPCIONAL: ver se o package.json está aqui)
|
||||
# RUN pwd && ls -la && ls -la src
|
||||
|
||||
# Instalar dependências e buildar
|
||||
RUN npm install && npm run build
|
||||
# Se quiser pode trocar npm ci por npm install
|
||||
RUN npm ci || npm install
|
||||
RUN npm run build
|
||||
|
||||
# Etapa 2 - Servir com NGINX
|
||||
# =========================
|
||||
# Etapa 2 - Nginx estático
|
||||
# =========================
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copiar a pasta dist gerada pelo Vite
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
# Remover completamente a página padrão do nginx
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
# Remover index default do nginx, se existir
|
||||
RUN rm -f /usr/share/nginx/html/index.html 2>/dev/null || true
|
||||
# Copiar o build do Vite
|
||||
COPY --from=build /app/dist/ /usr/share/nginx/html/
|
||||
|
||||
# (DEBUG OPCIONAL: ver o que ficou na pasta pública)
|
||||
# RUN ls -R /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
Reference in New Issue
Block a user