Atualizar Dockerfile
This commit is contained in:
31
Dockerfile
31
Dockerfile
@@ -1,5 +1,5 @@
|
||||
# Etapa 1 - extrair e buildar a aplicação
|
||||
FROM node:18 as build
|
||||
FROM node:18 AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -15,8 +15,33 @@ RUN npm install && npm run build
|
||||
# Etapa 2 - imagem final com nginx
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copiar configuração nginx customizada para SPA
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# Configuração customizada do nginx para SPA
|
||||
RUN cat <<'EOF' > /etc/nginx/conf.d/default.conf
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
|
||||
|
||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location ~ /\. {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Copiar os arquivos construídos para o diretório público do nginx
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
Reference in New Issue
Block a user