version: '3.9'

services:
  backend:
    image: golang:1.24
    working_dir: /app/backend
    command: bash -lc "go run ./cmd/app"
    environment:
      PORT: 8080
      DATABASE_DRIVER: sqlite3
      DATABASE_URL: file:./data/matosbox.db?_fk=1
      ATTACHMENTS_DIR: ./data/pieces_jointes
      BACKUP_DIR: ./data/backups
      MAX_UPLOAD_MB: 50
      CONFIG_PATH: ./data/config.json
      DEBUG_LOG_PATH: ./data/logs/backend.log
    volumes:
      - ./:/app
      - ./data:/app/data
    ports:
      - "8080:8080"

  postgres:
    profiles: ["postgres"]
    image: postgres:16
    environment:
      POSTGRES_DB: matosbox
      POSTGRES_USER: matosbox
      POSTGRES_PASSWORD: matosbox
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:
