entire app update:
Some checks failed
Build and Deploy Flask App / test (pull_request) Has been cancelled
Build and Deploy Flask App / build-and-push (pull_request) Has been cancelled
Build and Deploy Flask App / deploy (pull_request) Has been cancelled

moder view app with static page, forgejo ci/cd workflow
This commit is contained in:
Norvicdev 2026-08-04 17:29:48 +03:00
parent 25c896f809
commit e6e700c2ee
13 changed files with 460 additions and 28 deletions

View file

@ -1,26 +1,34 @@
FROM python:3.12-slim
# Установка curl для healthcheck
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Многоступенчатая сборка для оптимизации
FROM python:3.14-slim as builder
WORKDIR /app
# Устанавливаем зависимости
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Финальный образ
FROM python:3.14-slim
WORKDIR /app
# Копируем зависимости из builder
COPY --from=builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Копируем код приложения
COPY . .
# Создаем non-root пользователя
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Создаем пользователя для запуска
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Экспортируем порт
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
CMD curl -f http://localhost:5000/health || exit 1
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:5000/health')" || exit 1
# Вариант 1: Запуск через Python
CMD ["python", "-c", "from main import app; app.run(host='0.0.0.0', port=5000)"]
# Вариант 2: Если используете gunicorn
# CMD ["gunicorn", "--bind", "0.0.0.0:5000", "main:app"]
# Запускаем через gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "run:app"]