Atualizar Dockerfile
This commit is contained in:
27
Dockerfile
27
Dockerfile
@@ -1,11 +1,30 @@
|
|||||||
|
# Etapa 1 - extrair e buildar a aplicação
|
||||||
|
FROM node:18 as build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copiar e descompactar o ZIP do repositório
|
||||||
|
COPY app.zip /app/
|
||||||
|
RUN apt-get update && apt-get install -y unzip && \
|
||||||
|
unzip app.zip -d . && \
|
||||||
|
rm app.zip
|
||||||
|
|
||||||
|
# Instalar dependências e buildar o projeto
|
||||||
|
RUN npm install && npm run build
|
||||||
|
|
||||||
|
# Etapa 2 - imagem final com nginx
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Apaga a página padrão do nginx
|
# Copiar configuração nginx customizada para SPA
|
||||||
RUN rm -rf /usr/share/nginx/html/*
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Cria uma página simples
|
# Copiar os arquivos construídos para o diretório público do nginx
|
||||||
RUN echo '<h1>OK - Dockerfile está sendo usado</h1>' > /usr/share/nginx/html/index.html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Remover arquivo default se existir (evita sobrescrever a index.html do build)
|
||||||
|
RUN rm -f /usr/share/nginx/html/index.html.orig 2>/dev/null || true
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user