Skip to content

Commit 1c3358f

Browse files
authored
build: fix dev environment (edgehog-device-manager#1419)
The `dev-backend` task tried to contact the unavailable `openfga` container trough http to initialize the store instead of relying on the `openfga-init` service. Fixed Signed-off-by: Luca Zaninotto <luca.zaninotto@secomind.com>
1 parent 737bf37 commit 1c3358f

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ services:
6262
labels:
6363
- "traefik.enable=true"
6464
# --- HTTP API (port 8080) ---
65-
- "traefik.http.routers.openfga-http.rule=Host(`openfga.${DOCKER_COMPOSE_EDGEHOG_BASE_DOMAIN}`)"
65+
- "traefik.http.routers.openfga-http.rule=Host(`api.openfga.${DOCKER_COMPOSE_EDGEHOG_BASE_DOMAIN}`)"
6666
- "traefik.http.routers.openfga-http.entrypoints=web"
6767
- "traefik.http.routers.openfga-http.service=openfga-http"
6868
- "traefik.http.services.openfga-http.loadbalancer.server.port=8080"
6969
# --- gRPC (port 8081) — requires a TCP/HTTP2 entrypoint in Traefik ---
70-
- "traefik.http.routers.openfga-grpc.rule=Host(`openfga.${DOCKER_COMPOSE_EDGEHOG_BASE_DOMAIN}`)"
71-
- "traefik.http.routers.openfga-grpc.entrypoints=grpc"
70+
- "traefik.http.routers.openfga-grpc.rule=Host(`grpc.openfga.${DOCKER_COMPOSE_EDGEHOG_BASE_DOMAIN}`)"
71+
- "traefik.http.routers.openfga-grpc.entrypoints=web"
7272
- "traefik.http.routers.openfga-grpc.service=openfga-grpc"
7373
- "traefik.http.services.openfga-grpc.loadbalancer.server.port=8081"
7474
- "traefik.http.services.openfga-grpc.loadbalancer.server.scheme=h2c"

dprint.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"**/schema.graphql",
1313
"frontend/**",
1414
"backend/CHANGELOG.md",
15-
"doc/CHANGELOG.md"
15+
"doc/CHANGELOG.md",
16+
"astarte/**",
17+
"edgehog-device-runtime/**"
1618
],
1719
"plugins": [
1820
"https://plugins.dprint.dev/json-0.21.0.wasm",

justfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ _edgehog-dev-backend:
160160
export SEEDS_TENANT_PRIVATE_KEY_FILE=./priv/repo/seeds/keys/tenant_private.pem
161161
# Init edgehog services
162162
docker compose down -v
163-
docker compose up -d edgehog-device-forwarder rustfs rustfs-init registry registry-auth registry-init openfga
163+
docker compose up -d edgehog-device-forwarder rustfs rustfs-init registry registry-auth registry-init openfga openfga-init
164164
# Init postgres locally, edgehog has to be able to reach it seamlessly
165165
(docker run --name edgehog-db -d -e "POSTGRES_HOST_AUTH_METHOD=trust" -p 5432:5432 --rm postgres && sleep 3) || true # skip if already up
166166
# `astarte` network gateway ip, a.k.a. edgehog's IP
@@ -180,8 +180,10 @@ _edgehog-dev-backend:
180180
export EDGEHOG_FORWARDER_SECURE_SESSIONS="false"
181181
export ADMIN_JWT_PUBLIC_KEY_PATH=./priv/repo/seeds/keys/admin_public.pem
182182
export AUTHZ_PROVIDER=openfga
183-
export OPENFGA_GRPC_ENDPOINT="openfga.edgehog.localhost:8081"
184-
export OPENFGA_STORE_ID=$(fga store create --model backend/priv/fga/model.fga --api-url "http://openfga.edgehog.localhost:8080" | jq -r .store.id)
183+
export OPENFGA_GRPC_ENDPOINT="http://grpc.openfga.edgehog.localhost"
184+
docker pull busybox
185+
docker wait openfga-init || true
186+
eval $(docker run --rm -v edgehog_fga-env:/vol busybox cat /vol/.env)
185187
cd backend
186188
mix deps.get
187189
# Setup database. Do not seed the database.

0 commit comments

Comments
 (0)