Replace Dockerfiles, Compose and Drone CI with clean working setup
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2026-03-18 20:02:20 +06:00
parent 7388962a7d
commit 389b92f68a
7 changed files with 108 additions and 400 deletions

View File

@@ -1,79 +1,30 @@
# ================================
# MC Panel Backend - Production Dockerfile
# ================================
FROM python:3.11-slim
FROM python:3.11-slim AS production
# Метаданные
LABEL maintainer="MC Panel Team" \
version="2.0.0" \
description="MC Panel Backend - FastAPI Server" \
component="backend"
# Переменные окружения
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
PORT=8000 \
WORKERS=1 \
DEBIAN_FRONTEND=noninteractive
WORKERS=2
# Устанавливаем системные зависимости
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
procps \
ca-certificates \
tini \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Создаем пользователя для безопасности
RUN groupadd -r -g 1000 mcpanel && \
useradd -r -u 1000 -g mcpanel -d /app -s /bin/bash mcpanel
# Создаем рабочую директорию
WORKDIR /app
# Копируем requirements и устанавливаем зависимости
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Копируем исходный код
COPY --chown=mcpanel:mcpanel . ./
COPY . ./
# Создаем необходимые директории
RUN mkdir -p \
servers \
data \
logs \
&& touch users.json tickets.json
RUN mkdir -p /app/servers /app/data /app/logs \
&& ([ -f /app/users.json ] || echo '{}' > /app/users.json) \
&& ([ -f /app/tickets.json ] || echo '{}' > /app/tickets.json)
# Создаем конфигурационные файлы по умолчанию если их нет
RUN [ ! -f users.json ] && echo '{}' > users.json || true && \
[ ! -f tickets.json ] && echo '{}' > tickets.json || true
# Устанавливаем права доступа
RUN chown -R mcpanel:mcpanel /app && \
chmod -R 755 /app && \
chmod +x main.py
# Переключаемся на непривилегированного пользователя
USER mcpanel
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:${PORT}/health 2>/dev/null || \
curl -f http://localhost:${PORT}/ 2>/dev/null || exit 1
# Expose порт
EXPOSE 8000
# Volumes для персистентных данных
VOLUME ["/app/servers", "/app/data", "/app/logs"]
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD curl -fsS "http://localhost:${PORT}/health" || exit 1
# Используем tini как init процесс
ENTRYPOINT ["/usr/bin/tini", "--"]
# Команда запуска
CMD ["sh", "-c", "python -m uvicorn main:app --host 0.0.0.0 --port ${PORT} --workers ${WORKERS}"]
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000} --workers ${WORKERS:-2}"]