docker compose

This commit is contained in:
2026-01-21 22:05:21 +00:00
parent 0df0baf822
commit 0f764b1239
3 changed files with 39 additions and 7 deletions

View File

@@ -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

View File

@@ -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"]
# 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;"]

14
geradoresfe/nginx.conf Normal file
View File

@@ -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;
}