164 lines
4.1 KiB
YAML
164 lines
4.1 KiB
YAML
version: "3.8"
|
|
|
|
services:
|
|
web:
|
|
image: "vlafvlaf/karrot_frontend:0.0.3"
|
|
configs:
|
|
- source: nginx_config
|
|
target: /etc/nginx/conf.d/default.conf
|
|
depends_on:
|
|
- app
|
|
environment:
|
|
- DOMAIN
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/"]
|
|
interval: 30s
|
|
timeout: 3s
|
|
retries: 30
|
|
networks:
|
|
- internal
|
|
- proxy
|
|
volumes:
|
|
- "app_data:/app/uploads"
|
|
deploy:
|
|
update_config:
|
|
failure_action: rollback
|
|
order: start-first
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80"
|
|
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
|
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
|
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
|
- "coop-cloud.${STACK_NAME}.version=0.0.1+testing"
|
|
|
|
app:
|
|
image: "vlafvlaf/karrot_backend:test"
|
|
networks:
|
|
- internal
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
volumes:
|
|
- "shiv_data:/root/.shiv"
|
|
- "geoip_data:/var/lib/GeoIP"
|
|
- "app_data:/app/uploads"
|
|
environment:
|
|
- MAXMIND_ACCOUNT_ID
|
|
- MAXMIND_LICENSE_KEY
|
|
- SITE_URL=http://localhost:8000
|
|
- LISTEN_HOST=0.0.0.0
|
|
- LISTEN_SERVER=uvicorn
|
|
- SECRET_KEY=foobar
|
|
- DATABASE_HOST=db
|
|
- DATABASE_PORT=5432
|
|
- DATABASE_NAME=karrot
|
|
- DATABASE_USER=karrot
|
|
- DATABASE_PASSWORD=karrot
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/api/"]
|
|
interval: 30s
|
|
timeout: 3s
|
|
retries: 90
|
|
command: >
|
|
sh -c "
|
|
echo 'EditionIDs GeoLite2-City GeoLite2-Country' > /etc/GeoIP.conf &&
|
|
echo AccountID $${MAXMIND_ACCOUNT_ID} >> /etc/GeoIP.conf &&
|
|
echo LicenseKey $${MAXMIND_LICENSE_KEY} >> /etc/GeoIP.conf &&
|
|
echo 'Updating geoip data, first time could be slow...' &&
|
|
geoipupdate &&
|
|
pip install tzdata &&
|
|
python karrot-backend.pyz migrate &&
|
|
python karrot-backend.pyz server
|
|
"
|
|
worker:
|
|
image: "vlafvlaf/karrot_backend:test"
|
|
depends_on:
|
|
# shiv + geoip data gets loaded on the first run of the app
|
|
# so to ensure it's available in the worker too, we need to wait
|
|
- app
|
|
volumes:
|
|
- "shiv_data:/root/.shiv"
|
|
- "geoip_data:/var/lib/GeoIP"
|
|
networks:
|
|
- internal
|
|
environment:
|
|
- SITE_URL=http://localhost:8000
|
|
- LISTEN_HOST=0.0.0.0
|
|
- LISTEN_SERVER=uvicorn
|
|
- SECRET_KEY=foobar
|
|
- DATABASE_HOST=db
|
|
- DATABASE_PORT=5432
|
|
- DATABASE_NAME=karrot
|
|
- DATABASE_USER=karrot
|
|
- DATABASE_PASSWORD=karrot
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0
|
|
command:
|
|
sh -c "
|
|
pip install tzdata &&
|
|
python karrot-backend.pyz worker"
|
|
|
|
redis:
|
|
image: "redis:6-alpine"
|
|
command: ["redis-server", "--appendonly", "yes"]
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 30
|
|
volumes:
|
|
- "redis_data:/data"
|
|
networks:
|
|
- internal
|
|
|
|
db:
|
|
image: "postgres:14-alpine"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U karrot"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 30
|
|
configs:
|
|
- source: postgres_extensions
|
|
target: /docker-entrypoint-initdb.d/extensions.sql
|
|
mode: 0555
|
|
volumes:
|
|
- "postgres_data:/var/lib/postgresql/data"
|
|
networks:
|
|
- internal
|
|
environment:
|
|
- POSTGRES_PASSWORD=karrot
|
|
- POSTGRES_USER=karrot
|
|
- POSTGRES_DB=karrot
|
|
|
|
|
|
secrets:
|
|
db_password:
|
|
external: true
|
|
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
|
|
|
|
configs:
|
|
nginx_config:
|
|
name: ${STACK_NAME}_nginx_config_${NGINX_CONFIG_VERSION}
|
|
file: nginx.conf.tmpl
|
|
template_driver: golang
|
|
postgres_extensions:
|
|
name: ${STACK_NAME}_postgres_extensions_${POSTGRES_ENTRYPOINT_VERSION}
|
|
file: pg_extensions.sql
|
|
|
|
volumes:
|
|
shiv_data:
|
|
geoip_data:
|
|
app_data:
|
|
postgres_data:
|
|
redis_data:
|
|
networks:
|
|
proxy:
|
|
external: true
|
|
internal:
|