name: vendoo
services:
  vendoo:
    build:
      context: .
      dockerfile: Dockerfile
    image: vendoo:1.42.0
    container_name: vendoo
    restart: unless-stopped
    init: true
    env_file:
      - .env
    environment:
      NODE_ENV: production
      PORT: 8124
      VENDOO_BIND_HOST: 0.0.0.0
      VENDOO_DATA_DIR: /app/data
      VENDOO_DB_PATH: /app/data/db/vendoo.db
      VENDOO_UPLOADS_DIR: /app/data/uploads
      VENDOO_BACKUP_DIR: /app/data/backups
      VENDOO_OPERATIONS_DIR: /app/data/operations
      VENDOO_LOG_DIR: /app/data/logs
      VENDOO_CONFIG_PATH: /app/data/config/vendoo.env
      VENDOO_REQUIRE_SETUP_TOKEN: "true"
      LOCAL_IMAGE_ENABLED: "${LOCAL_IMAGE_ENABLED:-false}"
    ports:
      - "${VENDOO_PUBLISH_ADDRESS:-127.0.0.1}:${VENDOO_HOST_PORT:-8124}:8124"
    expose:
      - "8124"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - vendoo_db:/app/data/db
      - vendoo_uploads:/app/data/uploads
      - vendoo_backups:/app/data/backups
      - vendoo_operations:/app/data/operations
      - vendoo_logs:/app/data/logs
      - vendoo_config:/app/data/config
      - vendoo_modules:/app/data/modules
    read_only: true
    tmpfs:
      - /tmp:size=512m,mode=1777
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL
    pids_limit: 256
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "5"
    stop_grace_period: 15s
    healthcheck:
      test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:8124/readyz').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
      interval: 30s
      timeout: 5s
      start_period: 30s
      retries: 3
    networks:
      - vendoo

networks:
  vendoo:
    driver: bridge

volumes:
  vendoo_db:
  vendoo_uploads:
  vendoo_backups:
  vendoo_operations:
  vendoo_logs:
  vendoo_config:
  vendoo_modules:
