# Plane.so - Self-Hosted Project Management
# Deployed via Portainer on TrueNAS Scale (guava)
# Port: 3080 (HTTP), 3443 (HTTPS)

x-db-env: &db-env
  PGHOST: plane-db
  PGDATABASE: plane
  POSTGRES_USER: plane
  POSTGRES_PASSWORD: "REDACTED_PASSWORD"
  POSTGRES_DB: plane
  POSTGRES_PORT: 5432
  PGDATA: /var/lib/postgresql/data

x-redis-env: &redis-env
  REDIS_HOST: plane-redis
  REDIS_PORT: 6379
  REDIS_URL: redis://plane-redis:6379/

x-minio-env: &minio-env
  MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID:-planeaccess}
  MINIO_ROOT_PASSWORD: "REDACTED_PASSWORD"

x-aws-s3-env: &aws-s3-env
  AWS_REGION: us-east-1
  AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-planeaccess}
  AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-planesecret123}
  AWS_S3_ENDPOINT_URL: http://plane-minio:9000
  AWS_S3_BUCKET_NAME: uploads

x-proxy-env: &proxy-env
  APP_DOMAIN: ${APP_DOMAIN:-guava.crista.home}
  FILE_SIZE_LIMIT: 52428800
  LISTEN_HTTP_PORT: 80
  LISTEN_HTTPS_PORT: 443
  BUCKET_NAME: uploads
  SITE_ADDRESS: :80

x-mq-env: &mq-env
  RABBITMQ_HOST: plane-mq
  RABBITMQ_PORT: 5672
  RABBITMQ_DEFAULT_USER: plane
  RABBITMQ_DEFAULT_PASS: "REDACTED_PASSWORD"REDACTED_PASSWORD"
  RABBITMQ_DEFAULT_VHOST: plane
  RABBITMQ_VHOST: plane

x-live-env: &live-env
  API_BASE_URL: http://api:8000
  LIVE_SERVER_SECRET_KEY: ${LIVE_SERVER_SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5}

x-app-env: &app-env
  WEB_URL: ${WEB_URL:-http://guava.crista.home:3080}
  DEBUG: 0
  CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:-}
  GUNICORN_WORKERS: 2
  USE_MINIO: 1
  DATABASE_URL: postgresql://plane:${POSTGRES_PASSWORD:"REDACTED_PASSWORD"
  SECRET_KEY: ${SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5}
  AMQP_URL: amqp://plane:${RABBITMQ_PASSWORD:"REDACTED_PASSWORD"
  API_KEY_RATE_LIMIT: 60/minute
  MINIO_ENDPOINT_SSL: 0
  LIVE_SERVER_SECRET_KEY: ${LIVE_SERVER_SECRET_KEY:-60gp0byfz2dvffa45cxl20p1scy9xbpf6d8c5y0geejgkyp1b5}

services:
  web:
    image: artifacts.plane.so/makeplane/plane-frontend:stable
    container_name: plane-web
    restart: unless-stopped
    depends_on:
      - api
      - worker

  space:
    image: artifacts.plane.so/makeplane/plane-space:stable
    container_name: plane-space
    restart: unless-stopped
    depends_on:
      - api
      - worker
      - web

  admin:
    image: artifacts.plane.so/makeplane/plane-admin:stable
    container_name: plane-admin
    restart: unless-stopped
    depends_on:
      - api
      - web

  live:
    image: artifacts.plane.so/makeplane/plane-live:stable
    container_name: plane-live
    restart: unless-stopped
    environment:
      <<: [*live-env, *redis-env]
    depends_on:
      - api
      - web

  api:
    image: artifacts.plane.so/makeplane/plane-backend:stable
    container_name: plane-api
    command: ./bin/docker-entrypoint-api.sh
    restart: unless-stopped
    environment:
      <<: [*app-env, *db-env, *redis-env, *minio-env, *aws-s3-env, *proxy-env]
    depends_on:
      plane-db:
        condition: service_healthy
      plane-redis:
        condition: service_started
      plane-mq:
        condition: service_started

  worker:
    image: artifacts.plane.so/makeplane/plane-backend:stable
    container_name: plane-worker
    command: ./bin/docker-entrypoint-worker.sh
    restart: unless-stopped
    environment:
      <<: [*app-env, *db-env, *redis-env, *minio-env, *aws-s3-env, *proxy-env]
    depends_on:
      - api
      - plane-db
      - plane-redis
      - plane-mq

  beat-worker:
    image: artifacts.plane.so/makeplane/plane-backend:stable
    container_name: plane-beat
    command: ./bin/docker-entrypoint-beat.sh
    restart: unless-stopped
    environment:
      <<: [*app-env, *db-env, *redis-env, *minio-env, *aws-s3-env, *proxy-env]
    depends_on:
      - api
      - plane-db
      - plane-redis
      - plane-mq

  migrator:
    image: artifacts.plane.so/makeplane/plane-backend:stable
    container_name: plane-migrator
    command: ./bin/docker-entrypoint-migrator.sh
    restart: on-failure
    environment:
      <<: [*app-env, *db-env, *redis-env, *minio-env, *aws-s3-env, *proxy-env]
    depends_on:
      plane-db:
        condition: service_healthy
      plane-redis:
        condition: service_started

  plane-db:
    image: postgres:15.7-alpine
    container_name: plane-db
    command: postgres -c 'max_connections=1000'
    restart: unless-stopped
    environment:
      <<: *db-env
    volumes:
      - /mnt/data/plane-data/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U plane -d plane"]
      interval: 10s
      timeout: 5s
      retries: 5

  plane-redis:
    image: valkey/valkey:7.2.11-alpine
    container_name: plane-redis
    restart: unless-stopped
    volumes:
      - /mnt/data/plane-data/redis:/data

  plane-mq:
    image: rabbitmq:3.13.6-management-alpine
    container_name: plane-mq
    restart: unless-stopped
    environment:
      <<: *mq-env
    volumes:
      - /mnt/data/plane-data/rabbitmq:/var/lib/rabbitmq

  plane-minio:
    image: minio/minio:latest
    container_name: plane-minio
    command: server /export --console-address ":9090"
    restart: unless-stopped
    environment:
      <<: *minio-env
    volumes:
      - /mnt/data/plane-data/minio:/export

  proxy:
    image: artifacts.plane.so/makeplane/plane-proxy:stable
    container_name: plane-proxy
    restart: unless-stopped
    environment:
      <<: *proxy-env
    ports:
      - "3080:80"
      - "3443:443"
    depends_on:
      - web
      - api
      - space
      - admin
      - live

networks:
  default:
    name: plane-network
    driver: bridge
