services:
  mareike-app:
    build:
      context: .
      dockerfile: docker/Dockerfile
      args:
        UID: 1000
        GID: 1000
    networks:
      - dev-local
    volumes:
      - ./:/var/www/html  # Dein Code

  mareike-nginx:
    build:
      context: .
      dockerfile: docker/Dockerfile.nginx

    labels:
        - "traefik.enable=true"
        - "traefik.http.routers.mareike.rule=Host(`mareike.local`) || Host(`admin.mareike.local`) || Host(`wilde-moehre.mareike.local`) || Host(`fennek.mareike.local`)"
        - "traefik.http.routers.mareike.entrypoints=websecure"
        - "traefik.http.routers.mareike.tls=true"
        - "traefik.http.services.mareike.loadbalancer.server.port=80"

        - "traefik.http.routers.mareike-http.rule=Host(`mareike.local`) || Host(`admin.mareike.local`) || Host(`wilde-moehre.mareike.local`)"
        - "traefik.http.routers.mareike-http.entrypoints=web"
        - "traefik.http.routers.mareike-http.middlewares=redirect-to-https"

        # Middleware definieren
        - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
    networks:
      - dev-local
    depends_on:
      - mareike-app
    volumes:
      - ./:/var/www/html  # Dein Code
      - ./docker/ssl/:/etc/nginx/certs
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf

  mareike-frontend:
    image: node:latest
    container_name: mareike-frontend
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    command: >
      sh -c "
        while true; do
          npm run build
          echo 'Vite Dev-Server beendet. Neustart in 3 Sekunden...'
          sleep 10
        done
      "

    networks:
      - dev-local

networks:
  dev-local:
    external: true
