version: "3.8"

services:
  wallabag:
    image: wallabag/wallabag:2.6.14
    restart: unless-stopped
    expose:
      - "80"
    depends_on:
      wallabag-db:
        condition: service_healthy
      wallabag-redis:
        condition: service_healthy
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - SYMFONY__ENV__DATABASE_DRIVER=pdo_mysql
      - SYMFONY__ENV__DATABASE_HOST=wallabag-db
      - SYMFONY__ENV__DATABASE_PORT=3306
      - SYMFONY__ENV__DATABASE_NAME=wallabag
      - SYMFONY__ENV__DATABASE_USER=wallabag
      - SYMFONY__ENV__DATABASE_PASSWORD=${SYMFONY__ENV__DATABASE_PASSWORD}
      - SYMFONY__ENV__DATABASE_CHARSET=utf8mb4
      - SYMFONY__ENV__DATABASE_TABLE_PREFIX=wallabag_
      - SYMFONY__ENV__MAILER_DSN=smtp://127.0.0.1
      - SYMFONY__ENV__FROM_EMAIL=${SYMFONY__ENV__FROM_EMAIL}
      - SYMFONY__ENV__DOMAIN_NAME=${SYMFONY__ENV__DOMAIN_NAME}
      - SYMFONY__ENV__SERVER_NAME=${SYMFONY__ENV__SERVER_NAME}
      - SYMFONY__ENV__SECRET=${SYMFONY__ENV__SECRET}
      - SYMFONY__ENV__REDIS_HOST=wallabag-redis
    volumes:
      - wallabag-images:/var/www/wallabag/web/assets/images

  wallabag-db:
    image: mariadb:11.4
    restart: unless-stopped
    environment:
      # Only the root password is set on purpose: the wallabag entrypoint
      # creates the database and user and runs `wallabag:install` itself.
      # Pre-creating the database (MARIADB_DATABASE) makes the entrypoint
      # skip the install, leaving an empty schema and a persistent HTTP 500.
      - MARIADB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    volumes:
      - wallabag-db-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 20s
      timeout: 5s
      retries: 10

  wallabag-redis:
    image: redis:7-alpine
    restart: unless-stopped
    volumes:
      - wallabag-redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 20s
      timeout: 5s
      retries: 10

volumes:
  wallabag-images:
  wallabag-db-data:
  wallabag-redis-data:
