services:
  postiz:
    image: ghcr.io/gitroomhq/postiz-app:latest
    container_name: postiz
    restart: always
    env_file: 
      - .env
    environment:
      # You must change these. Replace `postiz.your-server.com` with your DNS name - this needs to be exactly the URL you're accessing Postiz on.
      # Be sure to add the domain to your local domain resolver e.g., Pi-Hole
      MAIN_URL: "https://postiz.${DOMAIN}"
      FRONTEND_URL: "https://postiz.${DOMAIN}"
      NEXT_PUBLIC_BACKEND_URL: "https://postiz.${DOMAIN}/api"
      JWT_SECRET: "sdfjhkj34sdkfhsdkfhsdkjfhsdf"
 
      # These defaults are probably fine, but if you change your user/password, update it in the
      # postiz-postgres or postiz-redis services below.
      DATABASE_URL: "postgresql://postiz-user:postiz-password@postiz-postgres:5432/postiz-db-local"
      REDIS_URL: "redis://postiz-redis:6379"
      BACKEND_INTERNAL_URL: "http://localhost:3000"
      IS_GENERAL: "true" # Required for self-hosting.
      # The container images are pre-configured to use /uploads for file storage.
      # You probably should not change this unless you have a really good reason!
      STORAGE_PROVIDER: "local"
      UPLOAD_DIRECTORY: "/uploads"
      NEXT_PUBLIC_UPLOAD_DIRECTORY: "/uploads"
    volumes:
      - ${WORKING_DIR}/postiz/config:/config/
      - ${WORKING_DIR}/postiz/uploads:/uploads/
      # if you prefer volumes
      # - postiz-config:/config/
      # - postiz-uploads:/uploads/
    # ports:
    #   - 5000:5000
    networks:
      - proxy
      - postiz-network
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.postiz.entrypoints=http"
      - "traefik.http.routers.postiz.rule=Host(`postiz.${DOMAIN}`)"
      - "traefik.http.middlewares.postiz-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.postiz.middlewares=postiz-https-redirect"
      - "traefik.http.routers.postiz-secure.entrypoints=https"
      - "traefik.http.routers.postiz-secure.rule=Host(`postiz.${DOMAIN}`)"
      - "traefik.http.routers.postiz-secure.tls=true"
      - "traefik.http.routers.postiz-secure.tls.certresolver=cloudflare"
      - "traefik.http.routers.postiz-secure.service=postiz"
      - "traefik.http.services.postiz.loadbalancer.server.port=5000"
    depends_on:
      postiz-postgres:
        condition: service_healthy
      postiz-redis:
        condition: service_healthy
 
  postiz-postgres:
    image: postgres:17-alpine
    container_name: postiz-postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: postiz-password
      POSTGRES_USER: postiz-user
      POSTGRES_DB: postiz-db-local
    volumes:
      - ${WORKING_DIR}/postiz/postgres:/var/lib/postgresql/data
      # if you prefer volumes
      # - postgres-volume:/var/lib/postgresql/data
    networks:
      - postiz-network
    healthcheck:
      test: pg_isready -U postiz-user -d postiz-db-local
      interval: 10s
      timeout: 3s
      retries: 3
  postiz-redis:
    image: redis:7.2
    container_name: postiz-redis
    restart: always
    healthcheck:
      test: redis-cli ping
      interval: 10s
      timeout: 3s
      retries: 3
    volumes:
      - ${WORKING_DIR}/postiz/redis:/data
      # if you prefer volumes
      # - postiz-redis-data:/data
    networks:
      - postiz-network

# if you prefer volumes
# volumes:
#   postgres-volume:
#     external: false
#   postiz-redis-data:
#     external: false
#   postiz-config:
#     external: false
#   postiz-uploads:
#     external: false
 
networks:
  proxy:
    external: true
  postiz-network:
    external: false