services:
  weblate:
    image: weblate/weblate:2026.7.1.1
    restart: unless-stopped
    depends_on:
      database:
        condition: service_healthy
      cache:
        condition: service_healthy
    volumes:
      - weblate-data:/app/data
      - weblate-cache:/app/cache
    tmpfs:
      - /run
      - /tmp
    environment:
      WEBLATE_SITE_DOMAIN: ${WEBLATE_SITE_DOMAIN}
      WEBLATE_SITE_TITLE: ${WEBLATE_SITE_TITLE}
      WEBLATE_ADMIN_NAME: ${WEBLATE_ADMIN_NAME}
      WEBLATE_ADMIN_EMAIL: ${WEBLATE_ADMIN_EMAIL}
      WEBLATE_ADMIN_PASSWORD: ${WEBLATE_ADMIN_PASSWORD}
      WEBLATE_SERVER_EMAIL: ${WEBLATE_SERVER_EMAIL}
      WEBLATE_DEFAULT_FROM_EMAIL: ${WEBLATE_DEFAULT_FROM_EMAIL}
      WEBLATE_ENABLE_HTTPS: ${WEBLATE_ENABLE_HTTPS}
      WEBLATE_ALLOWED_HOSTS: "*"
      WEBLATE_REGISTRATION_OPEN: ${WEBLATE_REGISTRATION_OPEN}
      POSTGRES_HOST: database
      POSTGRES_PORT: 5432
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      REDIS_HOST: cache
      REDIS_PORT: 6379

  database:
    image: postgres:18-alpine
    restart: unless-stopped
    volumes:
      - weblate-postgres-data:/var/lib/postgresql
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5

  cache:
    image: redis:8-alpine
    restart: unless-stopped
    command: ["redis-server", "--save", "60", "1", "--loglevel", "warning"]
    volumes:
      - weblate-redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  weblate-data:
  weblate-cache:
  weblate-postgres-data:
  weblate-redis-data:
