version: '3.8'

services:
  postiz:
    image: ghcr.io/gitroomhq/postiz-app:latest
    container_name: postiz
    restart: unless-stopped
    env_file: .env
    depends_on:
      postiz-postgres:
        condition: service_healthy
      postiz-redis:
        condition: service_healthy
    networks:
      - traefik-public
      - postiz-internal
    volumes:
      - postiz-uploads:/uploads
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik-public"

      # Service port
      - "traefik.http.services.postiz.loadbalancer.server.port=5000"

      # Routing configured in /opt/00-infrastructure/traefik/config/dynamic.yml
      # - postiz-api: /api routes (no SSO)
      # - postiz: frontend routes (with Authentik)

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

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

volumes:
  postiz-uploads:
    external: true
    name: postiz_postiz-uploads
  postiz-postgres-data:
    external: true
    name: postiz_postiz-postgres-data
  postiz-redis-data:
    external: true
    name: postiz_postiz-redis-data

networks:
  traefik-public:
    external: true
  postiz-internal:
    driver: bridge
