services:
  app:
    image: registry.gitlab.com/dev-initialde/transportdosapi:${IMAGE_TAG}
    ports:
      - "9096:9090"
    environment:
      SPRING_PROFILES_ACTIVE: prod
      SPRING_DATASOURCE_URL: ${POSTGRES_URL}
      SPRING_DATASOURCE_USERNAME: ${POSTGRES_USERNAME}
      SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      # CORS Configuration - À PERSONNALISER avec vos domaines de production
      # Exemple: CORS_ALLOWED_ORIGINS: "https://api.votre-domaine.com,https://app.votre-domaine.com"
      CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:-https://localhost:9090}
    depends_on:
      - postgres
      - redis
    networks:
      - transport-document-net
    volumes:
      - uploads_data:/var/app/uploads
      - temp_uploads_data:/var/app/temp/uploads
    restart: always
    env_file:
      - .env

  postgres:
    image: postgres:15
    container_name: transport-document-postgres
    environment:
      POSTGRES_DB: transportDocument
      POSTGRES_USER: initial_user
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - transport-document-net
    restart: always

  redis:
    image: redis:7-alpine
    container_name: transport-document-cache
    ports:
      - "6382:6379"
    command: [ "redis-server", "/redis/config/redis.conf" ]
    volumes:
      - ./redis/config:/redis/config
      - ./redis/data:/redis/data
      - ./redis/log:/redis/log
    networks:
      - transport-document-net
    restart: unless-stopped

volumes:
  postgres_data:
  uploads_data:
  temp_uploads_data:

networks:
  transport-document-net:
    driver: bridge
