diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1cda462 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.venv +**/*.pyc + +data/db/* +data/static/avatars/* +!data/static/avatars/default.webp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c718095 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:3.13-slim + +RUN apt-get update && apt-get install -y \ + nginx \ + uwsgi \ + uwsgi-plugin-python3 \ + sqlite3 \ + libargon2 \ + imagemagick \ + && rm -rf /var/lib/apt/lists/* + +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +WORKDIR /app +COPY requirements.txt . +RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt + +COPY . . + +RUN mkdir -p /app/data/static +RUN mkdir -p /app/data/db + +RUN chown -R www-data:www-data /app/data/ +COPY nginx.conf /etc/nginx/nginx.conf +COPY uwsgi.ini /app/ + +CMD ["sh", "-c", "uwsgi --ini uwsgi.ini & nginx -g 'daemon off;'"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..706a5c2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + pyrom: + build: . + ports: + - "8080:8080" + volumes: + - ./data/static:/app/data/static + - ./data/db:/app/data/db + environment: + - PYROM_PROD=true + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..06a00aa --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +events { + worker_connections 1024; +} + +http { + server { + listen 8080; + server_name localhost; + + location /static/ { + alias /data/static/; + } + + location / { + include uwsgi_params; + uwsgi_pass unix:///tmp/uwsgi.sock; + } + } +} diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 0000000..b2cb55c --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,14 @@ +[uwsgi] +module = app:create_app() +callable = app +master = true +processes = 2 +socket = /tmp/uwsgi.sock +chmod-socket = 666 +plugins = python3 + +virtualenv = /opt/venv +pythonpath = /opt/venv/lib/python3.13/site-packages + +uid = www-data +gid = www-data