jeremy há 4 meses atrás
pai
commit
102a51d672
4 ficheiros alterados com 25 adições e 3 exclusões
  1. 3 0
      .env.example
  2. 2 2
      docker-compose.yml
  3. 2 1
      frontend/Dockerfile
  4. 18 0
      frontend/nginx.conf.template

+ 3 - 0
.env.example

@@ -5,6 +5,9 @@ PGPASSWORD=postgres
 PGDATABASE=gestion_locative
 JWT_SECRET=change_this_secret_in_production
 
+# URL du backend vue par le conteneur frontend (nginx reverse proxy)
+BACKEND_URL=http://backend:3001
+
 # SSO OIDC (optionnel — laisser vide pour désactiver le bouton SSO)
 OIDC_ISSUER=https://your-provider.example.com/realms/myrealm
 OIDC_CLIENT_ID=gestion-locative

+ 2 - 2
docker-compose.yml

@@ -45,10 +45,10 @@ services:
     build:
       context: ./frontend
       dockerfile: Dockerfile
-      args:
-        VITE_API_URL: http://localhost:3001
     ports:
       - "3000:80"
+    environment:
+      - BACKEND_URL=${BACKEND_URL:-http://backend:3001}
     depends_on:
       - backend
     restart: unless-stopped

+ 2 - 1
frontend/Dockerfile

@@ -10,7 +10,8 @@ RUN npm run build
 
 FROM nginx:alpine
 COPY --from=build /app/dist /usr/share/nginx/html
-COPY nginx.conf /etc/nginx/conf.d/default.conf
+# Template processed at container start via envsubst
+COPY nginx.conf.template /etc/nginx/templates/default.conf.template
 
 EXPOSE 80
 CMD ["nginx", "-g", "daemon off;"]

+ 18 - 0
frontend/nginx.conf.template

@@ -0,0 +1,18 @@
+server {
+    listen 80;
+    root /usr/share/nginx/html;
+    index index.html;
+
+    # Proxy API calls to backend
+    location /api/ {
+        proxy_pass ${BACKEND_URL}/api/;
+        proxy_http_version 1.1;
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+    }
+
+    # SPA fallback
+    location / {
+        try_files $uri $uri/ /index.html;
+    }
+}