karrot/compose.yml

178 lines
4.4 KiB
YAML

version: "3.8"
services:
web:
image: "vlafvlaf/karrot_frontend:0.1.0"
configs:
- source: nginx_config
target: /etc/nginx/conf.d/default.conf
depends_on:
- app
environment:
- DOMAIN
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/api/bootstrap"]
interval: 15s
timeout: 3s
retries: 2
start_period: 45s
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}"
app:
image: "vlafvlaf/karrot_backend:0.1.0"
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
- EMAIL_BACKEND
- EMAIL_FROM
- SMTP_USER
- SMTP_PASSWORD
- SMTP_HOST
- SMTP_USE_SLL
- SMTP_USE_TLS
- SMTP_PORT
- SITE_URL
- SITE_NAME
- SITE_LOGO
- 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: 15s
timeout: 3s
retries: 2
start_period: 45s
deploy:
labels:
- "coop-cloud.${STACK_NAME}.version=0.1.0+0.1.0"
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:0.1.0"
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
- 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: