diff --git a/README.md b/README.md index 4ff1dd0..34eeda9 100644 --- a/README.md +++ b/README.md @@ -102,16 +102,34 @@ Copy the file `.env.sample` to `.env` and add your Spotify API Key. ### Starting the application -We use `docker-compose` to provide a full local development environment. +We use `docker compose` to provide a full local development environment. ```bash -$ docker-compose up +$ docker compose up ``` You can now access the frontend at `http://localhost:3000` and the API at `http://localhost:3000/api`. Frontend and API will automatically reload on any code changes. +### REPL Console + +You can start the REPL console by starting the normal environment, and then running: + +```bash +$ docker compose run console +``` + +### Observability + +If you want to start the observability suite (Metrics & Tracing) locally, you can use the `observability` docker compose profile: + +```bash +$ docker compose --profile observability up +``` + +Grafana is then available at `http://localhost:2345` and all sources are preconfigured. + ## Test ```bash diff --git a/docker-compose.yml b/docker-compose.yml index b883ab7..3ee826e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,10 @@ x-logging: &default-logging tag: "{{.Name}}" services: + ##### + ## Required services for listory + ##### + db: image: postgres:14.5 environment: @@ -84,6 +88,10 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events + ##### + ## console REPL + ##### + console: profiles: - console @@ -112,6 +120,93 @@ services: - db logging: *default-logging + ##### + ## Observability + ## Adopted from https://github.com/stefanprodan/dockprom/blob/master/docker-compose.yml + ##### + + prometheus: + profiles: ["observability"] + image: prom/prometheus:v2.38.0 + volumes: + - ./observability/prometheus:/etc/prometheus + - prometheus_data:/prometheus + command: + - "--config.file=/etc/prometheus/prometheus.yml" + - "--storage.tsdb.path=/prometheus" + - "--storage.tsdb.retention.time=200h" + - "--web.enable-lifecycle" + ports: + - 9090:9090 + networks: + - observability + - web + + loki: + profiles: ["observability"] + image: grafana/loki:2.6.1 + command: ["-config.file=/etc/loki/loki.yaml"] + ports: + - "3100" # loki needs to be exposed so it receives logs + volumes: + - ./observability/loki/loki.yaml:/etc/loki/loki.yaml + networks: + - observability + + promtail: + profiles: ["observability"] + image: grafana/promtail:2.6.1 + command: ["-config.file=/etc/promtail.yaml"] + volumes: + - ./observability/promtail/promtail.yaml:/etc/promtail.yaml + - /var/lib/docker/containers:/var/lib/docker/containers:ro + + - /var/log/journal/:/var/log/journal/ + - /run/log/journal/:/run/log/journal/ + - /etc/machine-id:/etc/machine-id + ports: + - "3102" + networks: + - observability + depends_on: + - loki + + tempo: + profiles: ["observability"] + image: grafana/tempo:1.5.0 + command: ["-config.file=/etc/tempo.yaml"] + volumes: + - ./observability/tempo/tempo.yaml:/etc/tempo.yaml + - tempo_data:/tmp/tempo + ports: + - "3101" # tempo + - "4318" # OpenTelemetry HTTP + networks: + - observability + - web + + grafana: + profiles: ["observability"] + image: grafana/grafana-oss:9.1.6 + volumes: + - ./observability/grafana/provisioning:/etc/grafana/provisioning + environment: + - GF_SECURITY_ADMIN_USER=listory + - GF_SECURITY_ADMIN_PASSWORD=listory + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_USERS_ALLOW_SIGN_UP=false + - GF_SERVER_HTTP_PORT=2345 + ports: + - 2345:2345 + networks: + - observability + +volumes: + prometheus_data: {} + tempo_data: {} + networks: db: {} web: {} + observability: {} diff --git a/observability/docker-compose.yml b/observability/docker-compose.yml deleted file mode 100644 index 44ddfa3..0000000 --- a/observability/docker-compose.yml +++ /dev/null @@ -1,86 +0,0 @@ -# Adopted from https://github.com/stefanprodan/dockprom/blob/master/docker-compose.yml - -version: "3.4" - -services: - prometheus: - image: prom/prometheus:v2.38.0 - volumes: - - ./prometheus:/etc/prometheus - - prometheus_data:/prometheus - command: - - "--config.file=/etc/prometheus/prometheus.yml" - - "--storage.tsdb.path=/prometheus" - - "--storage.tsdb.retention.time=200h" - - "--web.enable-lifecycle" - ports: - - 9090:9090 - networks: - - observability - - api - - loki: - image: grafana/loki:2.6.1 - command: ["-config.file=/etc/loki/loki.yaml"] - ports: - - "3100" # loki needs to be exposed so it receives logs - volumes: - - ./loki/loki.yaml:/etc/loki/loki.yaml - networks: - - observability - - promtail: - image: grafana/promtail:2.6.1 - command: ["-config.file=/etc/promtail.yaml"] - volumes: - - ./promtail/promtail.yaml:/etc/promtail.yaml - - /var/lib/docker/containers:/var/lib/docker/containers:ro - - - /var/log/journal/:/var/log/journal/ - - /run/log/journal/:/run/log/journal/ - - /etc/machine-id:/etc/machine-id - ports: - - "3102" - networks: - - observability - depends_on: - - loki - - tempo: - image: grafana/tempo:1.5.0 - command: ["-config.file=/etc/tempo.yaml"] - volumes: - - ./tempo/tempo.yaml:/etc/tempo.yaml - - tempo_data:/tmp/tempo - ports: - - "3101" # tempo - - "4318" # OpenTelemetry HTTP - networks: - - observability - - api - - grafana: - image: grafana/grafana-oss:9.1.6 - volumes: - - ./grafana/provisioning:/etc/grafana/provisioning - environment: - - GF_SECURITY_ADMIN_USER=listory - - GF_SECURITY_ADMIN_PASSWORD=listory - - GF_AUTH_ANONYMOUS_ENABLED=true - - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - - GF_USERS_ALLOW_SIGN_UP=false - - GF_SERVER_HTTP_PORT=2345 - ports: - - 2345:2345 - networks: - - observability - -volumes: - prometheus_data: {} - tempo_data: {} - -networks: - observability: {} - api: - external: true - name: listory_web diff --git a/observability/tempo/tempo.yaml b/observability/tempo/tempo.yaml index 66b0b6d..c5a2598 100644 --- a/observability/tempo/tempo.yaml +++ b/observability/tempo/tempo.yaml @@ -34,3 +34,6 @@ storage: pool: max_workers: 100 # the worker pool mainly drives querying, but is also used for polling the blocklist queue_depth: 10000 + +# Enable search functionality +search_enabled: true