add docker file

This commit is contained in:
2025-08-31 18:26:36 +03:00
parent 876ddec94a
commit 3c420c1b7b
5 changed files with 132 additions and 28 deletions

View File

@@ -0,0 +1,41 @@
FROM python:3.12-slim
# System deps: nginx & supervisor
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx supervisor && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Python deps
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
# App code
COPY server /app/server
COPY client /app/client
# Nginx config
COPY deploy/nginx.conf /etc/nginx/nginx.conf
# Supervisor config
COPY deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Nginx needs a pid file path
RUN mkdir -p /var/run/nginx
# Environment defaults
ENV TZ=Europe/Bucharest \
API_BIND=127.0.0.1:5000 \
FLET_BIND=127.0.0.1:8080 \
API_BASE_PATH=/api
# Expose only 80 internally (for nginx)
EXPOSE 80
# Healthcheck (API ping)
HEALTHCHECK --interval=30s --timeout=5s --retries=5 CMD \
wget -qO- http://127.0.0.1/api/health || exit 1
# Run all processes via supervisor
CMD ["/usr/bin/supervisord","-c","/etc/supervisor/conf.d/supervisord.conf"]

View File

@@ -1,5 +0,0 @@
flet==0.28.3
requests==2.32.3
python-dotenv==1.0.1
flet-web==0.28.3
flet-webview==0.1.0

View File

@@ -0,0 +1,44 @@
worker_processes auto;
events { worker_connections 1024; }
http {
sendfile on;
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $host "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
access_log /dev/stdout main;
error_log /dev/stderr warn;
# Upstreams (internal)
upstream api_upstream { server 127.0.0.1:5000; }
upstream flet_upstream { server 127.0.0.1:8080; }
server {
listen 80 default_server;
server_name _;
# API at /api -> Flask (gunicorn)
location /api/ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://api_upstream/;
}
# Everything else -> Flet web app
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://flet_upstream;
}
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
}

View File

@@ -0,0 +1,47 @@
[supervisord]
nodaemon=true
logfile=/dev/null
pidfile=/var/run/supervisord.pid
; --- Flask API (gunicorn) ---
[program:api]
directory=/app/server
command=/usr/local/bin/gunicorn --bind %(ENV_API_BIND)s --workers 2 --threads 4 app:app
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
startsecs=2
stopasgroup=true
killasgroup=true
; --- Flet web app ---
; If your app reads API URL from env, set it here as a relative path (/api)
[program:flet]
directory=/app/client
environment=API_BASE_URL="%(ENV_API_BASE_PATH)s"
command=/usr/local/bin/flet run --web --port 8080 main.py
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
startsecs=2
stopasgroup=true
killasgroup=true
; --- Nginx (foreground) ---
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
startsecs=2
stopasgroup=true
killasgroup=true

View File

@@ -1,23 +0,0 @@
# --- Flask API (server) requirements ---
# Web framework
Flask==2.3.3
Flask-Cors==4.0.0
Flask-JWT-Extended==4.6.0
# WSGI server
gunicorn==22.0.0
# Database (Postgres)
psycopg[binary]==3.2.1
# Utilities
python-dotenv==1.0.1
requests==2.32.3
# Features used by your server
geopy==2.4.1
reportlab>=3.6.12
PyPDF2==3.0.1
APScheduler==3.10.4
tzlocal==5.2