From 17226dc9253e62624c6e5a32188036cb5f74fdb1 Mon Sep 17 00:00:00 2001 From: InviteMe Developer Date: Mon, 31 Aug 2026 13:08:53 +0300 Subject: [PATCH] Add Docker support and update requirements --- .dockerignore | 17 +++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ requirements.txt | 2 ++ run_waitress.py | 7 +++++-- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f65d582 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +.git +.gitignore +venv/ +.env +.env.* +instance/ +__pycache__/ +*.pyc +*.pyo +*.pyd +.Python +*.db +*.sqlite3 +app/static/uploads/* +!app/static/uploads/.gitkeep +111.txt +inviteme_logo.png diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ab9364d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Системные зависимости: шрифты и библиотеки для Pillow/reportlab +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libjpeg-dev \ + zlib1g-dev \ + libfreetype6-dev \ + libpng-dev \ + libffi-dev \ + libxml2-dev \ + libxslt1-dev \ + fonts-dejavu-core \ + fonts-liberation \ + && rm -rf /var/lib/apt/lists/* + +# Зависимости Python +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Копируем код приложения +COPY . . + +# Порт, который слушает Waitress +EXPOSE 8888 + +CMD ["python", "run_waitress.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d295781 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: "3.8" + +services: + inviteme: + build: . + container_name: inviteme + restart: unless-stopped + ports: + - "8888:8888" + environment: + # Замени на сильный случайный ключ + - SECRET_KEY=change-me-in-production + - BASE_URL=https://ai.mycloud24.ru + - TIMEZONE=Europe/Moscow + # Первоначальные учётные записи (только при первом запуске) + - ADMIN_USERNAME=admin + - ADMIN_PASSWORD=change-admin-password + - STAFF_USERNAME=staff + - STAFF_PASSWORD=change-staff-password + volumes: + # База SQLite и загруженные файлы хранятся вне контейнера + - ./instance:/app/instance + - ./app/static/uploads:/app/app/static/uploads diff --git a/requirements.txt b/requirements.txt index bea4639..c8e5bf1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,5 @@ Jinja2==3.1.2 svglib==2.2.0 reportlab==5.0.1 rlPyCairo==0.4.0 +exchangelib==5.6.0 +pywin32==312; platform_system=="Windows" diff --git a/run_waitress.py b/run_waitress.py index e11d432..e1dc435 100644 --- a/run_waitress.py +++ b/run_waitress.py @@ -1,3 +1,5 @@ +import os + from waitress import serve from app import create_app @@ -5,5 +7,6 @@ app = create_app() if __name__ == "__main__": # host=0.0.0.0 — слушаем все интерфейсы - # port=8888 — порт, на который Nginx проксирует запросы - serve(app, host="0.0.0.0", port=8888, threads=4) + # port — из переменной окружения или 8888 по умолчанию + port = int(os.environ.get("PORT", "8888")) + serve(app, host="0.0.0.0", port=port, threads=4)