From 0f764b1239c1d576d8ab6bed84552a9ce7b707de Mon Sep 17 00:00:00 2001 From: Marco Santos Date: Wed, 21 Jan 2026 22:05:21 +0000 Subject: [PATCH] docker compose --- docker-compose.yml | 4 ++-- geradoresfe/Dockerfile | 28 +++++++++++++++++++++++----- geradoresfe/nginx.conf | 14 ++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 geradoresfe/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index 81b693b..605b7c1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,11 +18,11 @@ services: dockerfile: Dockerfile image: docker.io/shini89/geradoresfe:latest ports: - - "3000:3000" + - "3000:80" depends_on: - geradoresws environment: - - REACT_APP_API_URL=http://localhost:5050/ + - VITE_API_URL=http://localhost:5050/ networks: - app-network diff --git a/geradoresfe/Dockerfile b/geradoresfe/Dockerfile index 192c0f0..bc54f7b 100644 --- a/geradoresfe/Dockerfile +++ b/geradoresfe/Dockerfile @@ -1,8 +1,26 @@ -FROM node:20-alpine +# ---------- BUILD ---------- +FROM node:20-alpine AS build + WORKDIR /app -COPY package.json . + +COPY package.json package-lock.json ./ RUN npm install + COPY . . -ENV REACT_APP_API_URL=http://localhost:5015/ -EXPOSE 3000 -CMD ["npm", "start"] \ No newline at end of file + +# Variável de ambiente correta para Vite +ENV VITE_API_URL=http://localhost:5050/ +RUN npm run build + +# ---------- SERVE ---------- +FROM nginx:alpine + +# Copia os ficheiros do build para a pasta do nginx +COPY --from=build /app/dist /usr/share/nginx/html + +# Configuração mínima do nginx (opcional: para SPA fallback) +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/geradoresfe/nginx.conf b/geradoresfe/nginx.conf new file mode 100644 index 0000000..f800718 --- /dev/null +++ b/geradoresfe/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 80; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri /index.html; + } + + # Optional: gzip + gzip on; + gzip_types text/plain application/javascript text/css application/json image/svg+xml; +}