From 35250f452507247067f859969b7b3dfb31e67ba4 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Thu, 19 Feb 2026 09:47:12 +0100 Subject: [PATCH] dockerisation --- Dockerfile | 21 +++++++++++++++ backend/src/requirements.txt | 3 +++ docker-compose.yml | 25 ++++++++++++++++++ nginx.conf | 51 ++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 Dockerfile create mode 100644 backend/src/requirements.txt create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..03e2644 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.11-slim + +WORKDIR /app + +# Installer les dépendances Python +COPY backend/src/requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copier le code +COPY backend/src /app/backend/src +COPY frontend /app/frontend +COPY components /app/components +COPY img /app/img +COPY index.html /app/ +COPY *.json /app/ +COPY vite.config.ts /app/ + +# Port Flask +EXPOSE 5000 + +CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "backend.src.api:app"] diff --git a/backend/src/requirements.txt b/backend/src/requirements.txt new file mode 100644 index 0000000..6119aea --- /dev/null +++ b/backend/src/requirements.txt @@ -0,0 +1,3 @@ +Flask==3.0.0 +flask-cors==4.0.0 +gunicorn==21.2.0 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..601a5cd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +services: + riichi: + build: . + ports: + - "5000:5000" + environment: + - FLASK_ENV=production + volumes: + - ./frontend:/app/frontend + - ./backend/src:/app/backend/src + restart: unless-stopped + + nginx: + image: nginx:latest + ports: + - "8019:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + - ./frontend:/usr/share/nginx/html/frontend + - ./index.html:/usr/share/nginx/html/index.html:ro + - ./components:/usr/share/nginx/html/components + - ./img:/usr/share/nginx/html/img + depends_on: + - riichi + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9e1911f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,51 @@ +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + sendfile on; + tcp_nopush on; + keepalive_timeout 65; + gzip on; + + server { + listen 80; + server_name riichi.cosmoris.fr; + + root /usr/share/nginx/html; + index index.html; + + # Servir les fichiers statiques + location / { + try_files $uri $uri/ /index.html; + } + + # Proxy vers le backend Flask + location /api/ { + proxy_pass http://riichi:5000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + # Cache pour les assets + location ~* \.(css|js|svg|png|jpg|jpeg|gif|ico)$ { + expires 1d; + add_header Cache-Control "public, immutable"; + } + } +}