diff --git a/db/.env.template b/db/.env.template new file mode 100644 index 0000000..b76ca87 --- /dev/null +++ b/db/.env.template @@ -0,0 +1,2 @@ +INFLUX_PORT=8181 +UI_PORT=8093 diff --git a/db/docker-compose.yml b/db/docker-compose.yml new file mode 100644 index 0000000..ae84fef --- /dev/null +++ b/db/docker-compose.yml @@ -0,0 +1,67 @@ +services: + influxdb: + image: influxdb:3-core + ports: + - "${INFLUX_PORT}:8181" + entrypoint: | + /bin/sh -c ' + RAW_TOKEN=$$(cat /run/secrets/admin-token) && + echo "{\"name\":\"admin\",\"token\":\"$$RAW_TOKEN\"}" > /tmp/admin-token.json && + exec influxdb3 serve \ + --node-id=node0 \ + --object-store=file \ + --data-dir=/var/lib/influxdb3/data \ + --admin-token-file=/tmp/admin-token.json \ + --disable-authz=health + ' + secrets: + - admin-token + volumes: + - influxdb3_data:/var/lib/influxdb3 + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8181/health"] + interval: 30s + timeout: 10s + retries: 5 + + explorer: + image: influxdata/influxdb3-ui + ports: + - "${UI_PORT}:80" + environment: + DEFAULT_INFLUX_SERVER: "http://influxdb:${INFLUX_PORT}" + DEFAULT_INFLUX_DATABASE: "provence" + DEFAULT_SERVER_NAME: "PI-E2EEDA" + depends_on: + influxdb: + condition: service_healthy + secrets: + - admin-token + entrypoint: > + /bin/sh -c ' + export DEFAULT_API_TOKEN=$$(cat /run/secrets/admin-token)' + restart: unless-stopped + + init-influx: + image: influxdb:3-core + restart: "no" + depends_on: + influxdb: + condition: service_healthy + secrets: + - admin-token + entrypoint: | + /bin/sh -c ' + influxdb3 create database \ + --host "http://influxdb:$${INFLUX_PORT:-8181}" \ + --token "$$(cat /run/secrets/admin-token)" \ + provence || echo "Database provence already exists" + ' + +volumes: + influxdb3_data: + +secrets: + admin-token: + file: ./secrets/admin-token.txt