networks:
  penpot:
  swag_lan:
    external: true

volumes:
  penpot_postgres_v15:
  penpot_assets:

services:
  penpot-frontend:
    image: penpotapp/frontend:latest
    restart: always
    ports:
      - "9001:8080"
    volumes:
      - penpot_assets:/opt/data/assets
    depends_on:
      - penpot-backend
      - penpot-exporter
    networks:
      - penpot
      - swag_lan
    environment:
      PENPOT_FLAGS: "disable-email-verification disable-secure-session-cookies enable-prepl-server"
      PENPOT_HTTP_SERVER_MAX_BODY_SIZE: "31457280"
      PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE: "367001600"

  penpot-backend:
    image: penpotapp/backend:latest
    restart: always
    volumes:
      - penpot_assets:/opt/data/assets
    depends_on:
      penpot-postgres:
        condition: service_healthy
      penpot-valkey:
        condition: service_healthy
    networks:
      - penpot
    environment:
      PENPOT_FLAGS: "disable-email-verification disable-secure-session-cookies enable-prepl-server"
      PENPOT_PUBLIC_URI: "http://192.168.1.150:9001"
      PENPOT_HTTP_SERVER_MAX_BODY_SIZE: "31457280"
      PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE: "367001600"
      PENPOT_SECRET_KEY: "W-qrv3Y7XdwqoemDRgVD3gp-yq8Pk0acDNDW3TBu6DfEy3tB6uohjySj488TQl0PfIwpfl2MiqqLIW64W3gMpw"
      PENPOT_DATABASE_URI: "postgresql://penpot-postgres/penpot"
      PENPOT_DATABASE_USERNAME: "penpot"
      PENPOT_DATABASE_PASSWORD: "penpot"
      PENPOT_REDIS_URI: "redis://penpot-valkey/0"
      PENPOT_OBJECTS_STORAGE_BACKEND: "fs"
      PENPOT_OBJECTS_STORAGE_FS_DIRECTORY: "/opt/data/assets"
      PENPOT_TELEMETRY_ENABLED: "false"

  penpot-exporter:
    image: penpotapp/exporter:latest
    restart: always
    depends_on:
      penpot-valkey:
        condition: service_healthy
    networks:
      - penpot
    environment:
      PENPOT_SECRET_KEY: "W-qrv3Y7XdwqoemDRgVD3gp-yq8Pk0acDNDW3TBu6DfEy3tB6uohjySj488TQl0PfIwpfl2MiqqLIW64W3gMpw"
      PENPOT_PUBLIC_URI: "http://penpot-frontend:8080"
      PENPOT_REDIS_URI: "redis://penpot-valkey/0"

  penpot-postgres:
    image: postgres:15
    restart: always
    stop_signal: SIGINT
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U penpot"]
      interval: 2s
      timeout: 10s
      retries: 5
      start_period: 2s
    volumes:
      - penpot_postgres_v15:/var/lib/postgresql/data
    networks:
      - penpot
    environment:
      POSTGRES_INITDB_ARGS: "--data-checksums"
      POSTGRES_DB: "penpot"
      POSTGRES_USER: "penpot"
      POSTGRES_PASSWORD: "penpot"

  penpot-valkey:
    image: valkey/valkey:8.1
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "valkey-cli ping | grep PONG"]
      interval: 1s
      timeout: 3s
      retries: 5
      start_period: 3s
    networks:
      - penpot
    environment:
      VALKEY_EXTRA_FLAGS: "--maxmemory 128mb --maxmemory-policy volatile-lfu"
