version: "3.8"

services:
  chirpstack:
    container_name: smart-city-chirpstack
    image: chirpstack/chirpstack:latest
    command: -c /etc/chirpstack
    restart: unless-stopped
    volumes:
      - ./configuration/chirpstack:/etc/chirpstack:ro
    environment:
      - MQTT_BROKER_HOST=chirpstack-mosquitto-1
      - REDIS_HOST=chirpstack-redis-1
      - POSTGRESQL_HOST=chirpstack-postgres-1
      - DATABASE_URL=postgres://chirpstack:chirpstack@chirpstack-postgres-1/chirpstack?sslmode=disable
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.chirpstack.rule=Host(`chirpstack.digitribe.fr`)"
      - "traefik.http.routers.chirpstack.entrypoints=websecure"
      - "traefik.http.routers.chirpstack.tls.certresolver=letsencrypt"
      - "traefik.http.services.chirpstack.loadbalancer.server.port=8080"
    networks:
      - smartcity-shared

  chirpstack-rest-api:
    container_name: smart-city-chirpstack-rest-api
    image: chirpstack/chirpstack-rest-api:4
    restart: unless-stopped
    command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure --cors-origins="*"
    depends_on:
      - chirpstack
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.chirpstack-api.rule=Host(`chirpstack-api.digitribe.fr`)"
      - "traefik.http.routers.chirpstack-api.entrypoints=websecure"
      - "traefik.http.routers.chirpstack-api.tls.certresolver=letsencrypt"
      - "traefik.http.services.chirpstack-api.loadbalancer.server.port=8090"
    networks:
      - smartcity-shared

networks:
  smartcity-shared:
    external: true
