services:
  app:
    image: crew_admin:dev
    container_name: crew_admin_app_dev
    restart: unless-stopped
    environment:
      - APP_ENV=${APP_ENV:-development}
      - APP_DEBUG=${APP_DEBUG:-true}
      - APP_URL=${APP_URL:-https://dev-admin.crewsportswear.app}
      - DB_CONNECTION=mysql
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT:-3306}
      - DB_DATABASE=${DB_DATABASE}
      - DB_USERNAME=${DB_USERNAME}
      - DB_PASSWORD=${DB_PASSWORD}
      - MINIO_ENDPOINT=${MINIO_ENDPOINT}
      - MINIO_KEY=${MINIO_KEY}
      - MINIO_SECRET=${MINIO_SECRET}
      - MINIO_BUCKET=${MINIO_BUCKET:-crew-admin}
      - MINIO_REGION=${MINIO_REGION:-us-east-1}
      - MINIO_USE_PATH_STYLE=${MINIO_USE_PATH_STYLE:-true}
      - MINIO_URL=${MINIO_URL:-https://minio.crewsportswear.app}
      - IMAGES_DIRECTORY=${IMAGES_DIRECTORY}
      - PRODUCTION_PRIVATE_SERVER=${PRODUCTION_PRIVATE_SERVER}
    volumes:
      - ./storage:/var/www/html/storage
      - ./public/uploads:/var/www/html/public/uploads
    labels:
      - "traefik.enable=true"
      # Development environment (dev-admin.crewsportswear.app)
      - "traefik.http.routers.crew-admin-dev.rule=Host(`dev-admin.crewsportswear.app`)"
      - "traefik.http.routers.crew-admin-dev.entrypoints=websecure"
      - "traefik.http.routers.crew-admin-dev.tls=true"
      - "traefik.http.routers.crew-admin-dev.tls.certresolver=le"
      - "traefik.http.services.crew-admin-dev.loadbalancer.server.port=80"
      # HTTP to HTTPS redirect
      - "traefik.http.routers.crew-admin-dev-http.rule=Host(`dev-admin.crewsportswear.app`)"
      - "traefik.http.routers.crew-admin-dev-http.entrypoints=web"
      - "traefik.http.routers.crew-admin-dev-http.middlewares=https-redirect"
      - "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
    networks:
      - traefik-public
      - crew-app-net
      - default

networks:
  traefik-public:
    external: true
  crew-app-net:
    external: true
  default:
    driver: bridge
