services:
  affine:
    image: ghcr.io/toeverything/affine-graphql:stable
    container_name: ${CONTAINER_NAME}
    restart: unless-stopped
    ports:
      - ${PANEL_APP_PORT_HTTP}:3010
      - ${PANEL_APP_PORT_HTTP_5555}:5555
    command:
      ['sh', '-c', 'node ./scripts/self-host-predeploy && node ./dist/index.js']
    volumes:
      - ./data/storage:/root/.affine/storage
      - ./data/config:/root/.affine/config
    networks:
      - 1panel-network
    environment:
      - NODE_OPTIONS="--import=./scripts/register.js"
      - AFFINE_CONFIG_PATH=/root/.affine/config
      - REDIS_SERVER_HOST=${PANEL_REDIS_HOST}
      - REDIS_SERVER_PORT=6379
      - REDIS_SERVER_PASSWORD=${PANEL_REDIS_ROOT_PASSWORD}
      - DATABASE_URL=postgres://${PANEL_DB_USER}:${PANEL_DB_USER_PASSWORD}@${PANEL_DB_HOST}:${PANEL_DB_PORT}/${PANEL_DB_NAME}
      - NODE_ENV=production
      - AFFINE_ADMIN_EMAIL=${AFFINE_ADMIN_EMAIL}
      - AFFINE_ADMIN_PASSWORD=${AFFINE_ADMIN_PASSWORD}
    logging:
      driver: 'json-file'
      options:
        max-size: '1000m'
    labels:
      createdBy: "Apps"
networks:
  1panel-network:
    external: true