feat: Add nginx configuration for static frontend serving
All checks were successful
continuous-integration/drone/push Build is passing

- Update docker-compose.yml to use nginx for static file serving
- Configure nginx to serve frontend static files and proxy API requests
- Add frontend-init container to copy static files to nginx volume
- Update nginx/default.conf with proper static file handling and gzip compression
- Add NGINX_SETUP.md documentation for nginx deployment
- Improve performance by separating static files from backend API

Changes:
- Frontend static files now served by nginx (better performance)
- Backend only handles API requests (port 8000, internal)
- Gzip compression and caching for static assets
- WebSocket support for console functionality
- Health check endpoint for monitoring
This commit is contained in:
2026-01-17 11:18:21 +06:00
parent 2d77f99e93
commit b781407334
4 changed files with 288 additions and 29 deletions

View File

@@ -1,37 +1,29 @@
version: '3.8'
services:
# MC Panel приложение
mc-panel:
build:
context: .
dockerfile: Dockerfile
container_name: mc-panel
restart: unless-stopped
ports:
- "80:8000" # Прямой доступ через порт 80
expose:
- "8000"
environment:
# ZITADEL OpenID Connect
- ZITADEL_ISSUER=${ZITADEL_ISSUER}
- ZITADEL_CLIENT_ID=${ZITADEL_CLIENT_ID}
- ZITADEL_CLIENT_SECRET=${ZITADEL_CLIENT_SECRET}
# URLs
- BASE_URL=${BASE_URL:-http://localhost}
- FRONTEND_URL=${FRONTEND_URL:-http://localhost}
# Security
- SECRET_KEY=${SECRET_KEY:-change-this-in-production}
# Python
- PYTHONUNBUFFERED=1
volumes:
# Персистентное хранилище для серверов
- ./data/servers:/app/backend/servers
# Персистентное хранилище для пользователей и тикетов
- ./data/users.json:/app/backend/users.json
- ./data/tickets.json:/app/backend/tickets.json
# Папка для данных демонов
- ./data:/app/data
networks:
- mc-panel-network
@@ -42,6 +34,39 @@ services:
retries: 3
start_period: 40s
nginx:
image: nginx:alpine
container_name: mc-panel-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/default.conf:/etc/nginx/nginx.conf:ro
- frontend-static:/usr/share/nginx/html:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
depends_on:
- frontend-init
- mc-panel
networks:
- mc-panel-network
frontend-init:
build:
context: .
dockerfile: Dockerfile
container_name: mc-panel-frontend-init
volumes:
- frontend-static:/tmp/frontend
command: sh -c "cp -r /app/frontend/dist/* /tmp/frontend/ 2>/dev/null || echo 'No files to copy'; echo 'Frontend initialization complete'"
restart: "no"
networks:
- mc-panel-network
networks:
mc-panel-network:
driver: bridge
driver: bridge
volumes:
frontend-static:
driver: local