services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: wikijs
      POSTGRES_PASSWORD: ${DB_PASS:-wikijsrocks}
      POSTGRES_USER: wikijs
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U wikijs"]
      interval: 10s
      timeout: 5s
      retries: 5
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data

  wiki:
    image: requarks/wiki:2
    depends_on:
      db:
        condition: service_healthy
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: ${DB_PASS:-wikijsrocks}
      DB_NAME: wikijs
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
    restart: unless-stopped
    ports:
      - "3010:3000"

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

volumes:
  db-data:
  redis-data:
