add docker stuff

This commit is contained in:
Lera Elvoé 2025-06-29 18:17:15 +03:00
parent 6c731b04d3
commit 765e445bbf
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
5 changed files with 80 additions and 0 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
.venv
**/*.pyc
data/db/*
data/static/avatars/*
!data/static/avatars/default.webp

28
Dockerfile Normal file
View File

@ -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;'"]

13
docker-compose.yml Normal file
View File

@ -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

19
nginx.conf Normal file
View File

@ -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;
}
}
}

14
uwsgi.ini Normal file
View File

@ -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