From 181f74119ad9bf4298e27b6b65da945fcf941294 Mon Sep 17 00:00:00 2001 From: Nabil Derouiche Date: Mon, 20 Apr 2026 20:48:40 +0100 Subject: [PATCH] feat(docker): ajout service frontend Flutter Web (Nginx port 3001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - frontend/Dockerfile : build multi-étapes (Flutter stable → Nginx alpine) - frontend/nginx.conf : SPA routing, cache assets, gzip - docker-compose.yml : service frontend sur port 3001 - Accessible via reverse proxy → https://app.rayhan.bolbol.tn Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 9 +++++++++ frontend/Dockerfile | 13 +++++++++++++ frontend/nginx.conf | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 frontend/Dockerfile create mode 100644 frontend/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index f0ecb13..3beb76e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,6 +44,15 @@ services: networks: - rayhan-net + frontend: + build: ./frontend + container_name: rayhan-frontend + restart: unless-stopped + ports: + - "3001:80" + networks: + - rayhan-net + volumes: mysql_data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..96f9dce --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,13 @@ +# Étape 1 : Build Flutter Web +FROM ghcr.io/cirruslabs/flutter:stable AS build +WORKDIR /app +COPY pubspec.yaml pubspec.lock* ./ +RUN flutter pub get +COPY . . +RUN flutter build web --release --base-href / + +# Étape 2 : Serveur Nginx +FROM nginx:alpine +COPY --from=build /app/build/web /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 diff --git a/frontend/nginx.conf b/frontend/nginx.conf new file mode 100644 index 0000000..0e04f1c --- /dev/null +++ b/frontend/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Flutter Web : toutes les routes pointent vers index.html (SPA) + location / { + try_files $uri $uri/ /index.html; + } + + # Cache des assets statiques + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + gzip on; + gzip_types text/plain text/css application/javascript application/json; +}