dockerisation
This commit is contained in:
parent
b12734adf6
commit
35250f4525
4 changed files with 100 additions and 0 deletions
21
Dockerfile
Normal file
21
Dockerfile
Normal file
|
|
@ -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"]
|
||||||
3
backend/src/requirements.txt
Normal file
3
backend/src/requirements.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
Flask==3.0.0
|
||||||
|
flask-cors==4.0.0
|
||||||
|
gunicorn==21.2.0
|
||||||
25
docker-compose.yml
Normal file
25
docker-compose.yml
Normal file
|
|
@ -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
|
||||||
51
nginx.conf
Normal file
51
nginx.conf
Normal file
|
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue