67 lines
1.8 KiB
YAML
67 lines
1.8 KiB
YAML
services:
|
|
mysql:
|
|
image: mysql:8.0.35
|
|
command:
|
|
- --character-set-server=utf8mb4
|
|
- --collation-server=utf8mb4_0900_ai_ci
|
|
- --default-time-zone=+08:00
|
|
- --sql-mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
|
|
environment:
|
|
MYSQL_DATABASE: hulumath
|
|
MYSQL_USER: hulumath
|
|
MYSQL_PASSWORD: local-only-password
|
|
MYSQL_ROOT_PASSWORD: local-root-only-password
|
|
ports:
|
|
- "127.0.0.1:3307:3306"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -uroot -p$$MYSQL_ROOT_PASSWORD --silent"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 30
|
|
volumes:
|
|
- mysql_data:/var/lib/mysql
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: ["redis-server", "--appendonly", "yes"]
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
volumes:
|
|
- redis_data:/data
|
|
|
|
migrate:
|
|
build: .
|
|
environment: &app-environment
|
|
DJANGO_DEBUG: "false"
|
|
DJANGO_SECRET_KEY: local-compose-secret-change-before-production
|
|
DJANGO_ALLOWED_HOSTS: localhost,127.0.0.1
|
|
DATABASE_URL: mysql://hulumath:local-only-password@mysql:3306/hulumath
|
|
REDIS_URL: redis://redis:6379/0
|
|
command: ["python", "manage.py", "migrate", "--noinput"]
|
|
depends_on:
|
|
mysql:
|
|
condition: service_healthy
|
|
|
|
web:
|
|
build: .
|
|
environment: *app-environment
|
|
ports:
|
|
- "8000:8000"
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/', timeout=3)"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
volumes:
|
|
mysql_data:
|
|
redis_data:
|