From 35f02e0f8a1f3a8aea5ede7bd1dd91aab531dad8 Mon Sep 17 00:00:00 2001 From: 0xawaz Date: Fri, 22 Nov 2024 16:53:08 +0100 Subject: [PATCH 1/2] build: add db migration service --- coprocessor/Makefile | 5 +---- .../docker-compose/docker-compose-db-migration.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 coprocessor/docker-compose/docker-compose-db-migration.yml diff --git a/coprocessor/Makefile b/coprocessor/Makefile index 0dcec43..0680a92 100644 --- a/coprocessor/Makefile +++ b/coprocessor/Makefile @@ -102,10 +102,7 @@ else ifeq ($(CENTRALIZED_KMS),true) else @echo "CENTRALIZED_KMS is set to an unrecognized value: $(CENTRALIZED_KMS)" endif - cp -v network-fhe-keys/* $(COPROCESSOR_PATH)/fhevm-engine/fhevm-keys - cd $(COPROCESSOR_PATH)/fhevm-engine/coprocessor && make init - - + COMPOSE_PROJECT_NAME=zama-kms-gateway docker compose -vvv -f docker-compose/docker-compose-db-migration.yml up -d --wait run-coprocessor: $(WORKDIR)/ check-coprocessor check-all-test-repo cd $(COPROCESSOR_PATH)/fhevm-engine/coprocessor && make cleanup diff --git a/coprocessor/docker-compose/docker-compose-db-migration.yml b/coprocessor/docker-compose/docker-compose-db-migration.yml new file mode 100644 index 0000000..d2f2951 --- /dev/null +++ b/coprocessor/docker-compose/docker-compose-db-migration.yml @@ -0,0 +1,14 @@ +services: + migration: + container_name: migration + image: ghcr.io/zama-ai/fhevm-db-migration:v1 + environment: + DATABASE_URL: postgresql://postgres:postgres@zama-kms-gateway-db-1:5432/coprocessor + volumes: + - ../network-fhe-keys/:/fhevm-keys/ + networks: + - zama-kms-gateway_default + +networks: + zama-kms-gateway_default: + external: true \ No newline at end of file From 9747812d1a618e8e4f6784ce404c8c6f67f47421 Mon Sep 17 00:00:00 2001 From: 0xawaz Date: Fri, 22 Nov 2024 19:06:32 +0100 Subject: [PATCH 2/2] fix: catch container exit code --- coprocessor/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coprocessor/Makefile b/coprocessor/Makefile index 0680a92..7c6a80d 100644 --- a/coprocessor/Makefile +++ b/coprocessor/Makefile @@ -102,7 +102,13 @@ else ifeq ($(CENTRALIZED_KMS),true) else @echo "CENTRALIZED_KMS is set to an unrecognized value: $(CENTRALIZED_KMS)" endif - COMPOSE_PROJECT_NAME=zama-kms-gateway docker compose -vvv -f docker-compose/docker-compose-db-migration.yml up -d --wait + @COMPOSE_PROJECT_NAME=zama-kms-gateway docker compose -vvv -f docker-compose/docker-compose-db-migration.yml up -d --wait || true + @if [ "$$(docker inspect -f '{{.State.ExitCode}}' migration)" -eq 0 ]; then \ + echo "Container exited with code 0, proceeding..."; \ + else \ + echo "Container did not exit successfully, failing..."; \ + exit 1; \ + fi run-coprocessor: $(WORKDIR)/ check-coprocessor check-all-test-repo cd $(COPROCESSOR_PATH)/fhevm-engine/coprocessor && make cleanup