services:
  redis:
    image: redis:alpine
    restart: unless-stopped

  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: farmafinder
      POSTGRES_USER: farmafinder
      POSTGRES_PASSWORD: ${PG_PASSWORD:-change-me-in-production}
    volumes:
      - postgres_data:/var/lib/postgresql/data

  backend:
    image: git.hacecalor.net/ichitux/farmafinder-backend:latest
    build:
      context: .
      dockerfile: backend/Dockerfile
    restart: unless-stopped
    ports:
      - "3001:3001"
    environment:
      PORT: "3001"
      NODE_ENV: production
      SESSION_SECRET: ${SESSION_SECRET:-change-me-in-production}
      CORS_ORIGIN: http://localhost:3000
      REDIS_HOST: redis
      REDIS_PORT: "6379"
      REDIS_PASSWORD: ${REDIS_PASSWORD:-}
      DATABASE_PATH: /app/data/database.sqlite
      FARMACIAS_WEBHOOK_URL: ${FARMACIAS_WEBHOOK_URL:-}
      PG_URL: postgresql://farmafinder:${PG_PASSWORD:-change-me-in-production}@postgres:5432/farmafinder
    volumes:
      - backend_data:/app/data
    depends_on:
      - redis
      - postgres

  frontend:
    image: git.hacecalor.net/ichitux/farmafinder-frontend:latest
    build: ./frontend
    restart: unless-stopped
    ports:
      - "3000:80"
    depends_on:
      - backend

volumes:
  backend_data:
  postgres_data:
