CI/CD build notifications
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-11-02 06:33:45 +09:00
parent d5f1809f5a
commit 01532e860a
10 changed files with 1104 additions and 42 deletions

109
backend/.dockerignore Normal file
View File

@@ -0,0 +1,109 @@
# Python bytecode
__pycache__/
*.py[cod]
*$py.class
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Django specific
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
media/
staticfiles/
# Development files
.git/
.gitignore
README.md
docs/
*.md
# IDE
.vscode/
.idea/
*.swp
*.swo
# CI/CD
.drone.yml
.github/
Dockerfile.dev
docker-compose*.yml
# Testing
pytest.ini
.pytest_cache/
test_*.py
*_test.py
tests/
# Migrations (включаем только для разработки)
# migrations/
# Static files (собираются при сборке)
static/
storage/
# Backup files
*.backup
*.bak
# OS files
.DS_Store
Thumbs.db
# Frontend files (не нужны в backend контейнере)
frontend/
node_modules/
package*.json
*.js.map
# Development scripts
scripts/
Makefile

View File

@@ -0,0 +1,65 @@
# Multi-stage Docker build для оптимального размера
FROM python:3.11-slim as base
# Установка системных зависимостей
RUN apt-get update && apt-get install -y \
gcc \
postgresql-client \
curl \
&& rm -rf /var/lib/apt/lists/*
# Создание пользователя приложения
RUN useradd --create-home --shell /bin/bash app
# Установка рабочей директории
WORKDIR /app
# Копирование и установка Python зависимостей
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Production stage
FROM base as production
# Build arguments для метаданных
ARG BUILD_VERSION=latest
ARG BUILD_DATE
ARG VCS_REF
# Метаданные образа
LABEL org.opencontainers.image.title="CatLink Backend" \
org.opencontainers.image.description="Django REST API для CatLink" \
org.opencontainers.image.version="$BUILD_VERSION" \
org.opencontainers.image.created="$BUILD_DATE" \
org.opencontainers.image.revision="$VCS_REF" \
org.opencontainers.image.source="https://github.com/smartsoltech/links"
# Копирование приложения
COPY --chown=app:app . .
# Создание необходимых директорий
RUN mkdir -p staticfiles media logs && \
chown -R app:app /app
# Переключение на пользователя приложения
USER app
# Сбор статических файлов
RUN python manage.py collectstatic --noinput
# Переменные окружения для продакшена
ENV PYTHONPATH="/app" \
PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE="backend.settings" \
PORT=8000
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:$PORT/api/health/ || exit 1
# Открытие порта
EXPOSE $PORT
# Команда запуска
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "--worker-class", "sync", "--worker-connections", "1000", "--max-requests", "1000", "--max-requests-jitter", "100", "backend.wsgi:application"]