services:
  postgres:
    image: postgres:16-alpine
    restart: always
    environment:
      POSTGRES_DB: travelmarinedb
      POSTGRES_USER: yacht
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change_me}
    volumes:
      - pg-data:/var/lib/postgresql/data
    ports:
      - '127.0.0.1:5432:5432'

  backend:
    build: .
    environment:
      NODE_ENV: production
      PORT: 4000
      DATABASE_URL: postgresql://yacht:${POSTGRES_PASSWORD:-change_me}@postgres:5432/travelmarinedb
      UPLOAD_PATH: ./uploads
      APP_URL: http://localhost:4000
    volumes:
      - ./uploads:/app/uploads
    depends_on:
      - postgres
    ports:
      - '127.0.0.1:4000:4000'
    restart: always

  pgbackup:
    image: prodrigestivill/postgres-backup-local:16
    restart: always
    depends_on:
      - postgres
    environment:
      POSTGRES_HOST: postgres
      POSTGRES_DB: yachtbooking
      POSTGRES_USER: yacht
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change_me}
      SCHEDULE: '0 3 * * *'
      BACKUP_KEEP_DAYS: 7
      BACKUP_KEEP_WEEKS: 4
      BACKUP_KEEP_MONTHS: 3
      BACKUP_DIR: /backups
    volumes:
      - pg-backups:/backups

volumes:
  pg-data:
  pg-backups:
