From 041e0f881d6de066da485b89bb00c367b8572a15 Mon Sep 17 00:00:00 2001 From: Vyom Yadav <73882557+Vyom-Yadav@users.noreply.github.com> Date: Sat, 27 Jan 2024 13:47:36 +0530 Subject: [PATCH] Update compose-migrate action to run openfga container alongside (#2209) Signed-off-by: Vyom-Yadav --- .github/workflows/compose-migrate.yml | 14 +++++++++++--- docker-compose.yaml | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compose-migrate.yml b/.github/workflows/compose-migrate.yml index 911b07a701..f4d2379203 100644 --- a/.github/workflows/compose-migrate.yml +++ b/.github/workflows/compose-migrate.yml @@ -16,15 +16,23 @@ jobs: go-version-file: 'go.mod' - name: Install ko uses: ko-build/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa # v0.6 + - name: Copy server-config.yaml + run: cp config/server-config.yaml.example server-config.yaml - name: Start containers - run: KO_DOCKER_REPO=ko.local make run-docker services="postgres migrate" + run: KO_DOCKER_REPO=ko.local make run-docker services="postgres migrate openfga" COMPOSE="docker compose" - name: Wait for the migrations to complete timeout-minutes: 1 run: | set -e - while [ "$(docker logs minder_migrate_1 | grep 'Database migration completed successfully')" = "" ]; do - sleep 1 + while [ "$(docker inspect -f '{{.State.Running}}' minder_migrate_up)" == "true" ]; do + sleep 1 done + + if [ "$(docker inspect -f '{{.State.ExitCode}}' minder_migrate_up)" != "0" ]; then + echo "Migrations failed" + docker logs minder_migrate_up + exit 1 + fi - name: Check that the database contains the tables found in the migrations folder run: "set -e\n\ntables=$(grep -Ri 'CREATE TABLE' database/migrations | sed -E 's/.*CREATE TABLE (IF NOT EXISTS )?(.*) \\(/\\2/i')\nfor table in $tables; do\n docker exec $(docker ps -a | grep postgres | awk '{print $1}') psql -U postgres -d minder -c \"SELECT * FROM $table\"\ndone \n" diff --git a/docker-compose.yaml b/docker-compose.yaml index 8a89b19dee..b448685637 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,6 +16,7 @@ version: '3.2' services: minder: + container_name: minder_sever build: . image: minder:latest @@ -66,6 +67,7 @@ services: keycloak: condition: service_healthy migrate: + container_name: minder_migrate_up build: . image: minder:latest @@ -92,6 +94,8 @@ services: depends_on: postgres: condition: service_healthy + openfga: + condition: service_healthy postgres: container_name: postgres_container image: postgres:15-alpine