Corporate proxy (Zscaler) causes npm to fail inside Docker builds with 'Exit handler never called' error. This approach builds frontend on host where npm works, then copies pre-built dist/ into Docker image. New files: - Dockerfile.prebuilt: Single-stage build, copies frontend/dist - docker-compose.prebuilt.yml: Uses Dockerfile.prebuilt - .dockerignore.prebuilt: Allows frontend/dist to be included - start-docker-quick.sh: Quick restart without rebuild - DOCKER-PREBUILT-APPROACH.md: Documents workaround and comparison Benefits: - Builds in 2-3 minutes (not 15+) - Works behind corporate proxy - Simpler to debug - Faster iteration Trade-off: Requires npm on host, two-step build process For production: CI/CD builds frontend + image, pushes to registry
66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
# Docker Compose using pre-built frontend
|
|
# Build frontend on host first: cd frontend && npm run build
|
|
# Then: docker compose -f docker-compose.prebuilt.yml build
|
|
|
|
services:
|
|
db:
|
|
image: mysql:8.4
|
|
environment:
|
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
|
MYSQL_DATABASE: shopdb_flask
|
|
MYSQL_USER: shopdb
|
|
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
|
volumes:
|
|
- db_data:/var/lib/mysql
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.prebuilt
|
|
ports:
|
|
- "${API_PORT:-5001}:5001"
|
|
environment:
|
|
- DATABASE_URL=mysql+pymysql://shopdb:${MYSQL_PASSWORD}@db:3306/shopdb_flask
|
|
- SECRET_KEY=${SECRET_KEY}
|
|
- JWT_SECRET_KEY=${JWT_SECRET_KEY}
|
|
- FLASK_ENV=${FLASK_ENV:-production}
|
|
- FLASK_DEBUG=${FLASK_DEBUG:-0}
|
|
- CORS_ORIGINS=${CORS_ORIGINS}
|
|
- SHOPDB_ENV_LABEL=${SHOPDB_ENV_LABEL}
|
|
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
|
- ZABBIX_URL=${ZABBIX_URL:-}
|
|
- ZABBIX_TOKEN=${ZABBIX_TOKEN:-}
|
|
- COLLECTOR_API_KEY=${COLLECTOR_API_KEY:-}
|
|
- COLLECTOR_API_KEY_ENDPOINTS=${COLLECTOR_API_KEY_ENDPOINTS:-}
|
|
volumes:
|
|
- instance_data:/app/instance
|
|
- ./plugins:/app/plugins:ro
|
|
- ./scripts:/app/scripts:ro
|
|
- ./certs:/app/certs:ro
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
command: >
|
|
gunicorn
|
|
--bind 0.0.0.0:5001
|
|
--workers 4
|
|
--worker-class gevent
|
|
--worker-connections 2000
|
|
--timeout 300
|
|
--certfile /app/certs/server.crt
|
|
--keyfile /app/certs/server.key
|
|
--access-logfile -
|
|
--error-logfile -
|
|
wsgi:app
|
|
|
|
volumes:
|
|
db_data:
|
|
instance_data:
|