From 5d3c31797b7ab00bf64e5b9330d9e17335d116eb Mon Sep 17 00:00:00 2001 From: Tim Geoghegan Date: Thu, 13 Jun 2024 12:43:27 -0700 Subject: [PATCH] Add healthcheck for divviup-api to compose.yaml (#1097) Adds a simple healthcheck on the `divviup-api` service in `compose.yaml` that tickles the health endpoint. Also adds a check to the Docker CI job that runs Docker compose and waits 120 seconds for it to become healthy. Part of #1096 --- .github/workflows/docker.yml | 33 +++++++++++++++++++++++++++++++++ compose.yaml | 4 +++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ea8bd29e..4703ad7a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -26,6 +26,7 @@ jobs: with: context: . push: false + load: true cache-from: | type=gha,scope=main-${{ matrix.rust-features }} type=gha,scope=${{ github.ref_name }}-${{ matrix.rust-features }} @@ -33,3 +34,35 @@ jobs: build-args: | GIT_REVISION=${{ steps.git.outputs.GIT_REVISION }} RUST_FEATURES=${{ matrix.rust-features }} + # Test the dev compose, which should use the images built earlier. Technically this is only + # interesting when feature integration-testing is on, but we may as well exercise both. + - name: Compose (dev) + id: compose-dev + run: docker compose -f compose.dev.yaml up --wait --wait-timeout 120 + - name: Inspect dev containers + if: ${{ failure() && steps.compose-dev.outcome != 'success' }} + run: | + docker compose ps + for NAME in `docker compose ps --format json | jq -r '.Name'`; do + docker inspect $NAME + done + + # Test the non-dev compose, which we use for demo purposes. This pulls images from remote repos, + # so no need to build anything. + # Ideally we'd test on macOS and Windows, too, but those runners don't have Docker: + # https://github.com/actions/runner-images/issues/2150 + # https://github.com/actions/runner/issues/904 + compose: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Compose + id: compose + run: docker compose up --wait --wait-timeout 120 + - name: Inspect containers + if: ${{ failure() && steps.compose.outcome != 'success' }} + run: | + docker compose ps + for NAME in `docker compose ps --format json | jq -r '.Name'`; do + docker inspect $NAME + done diff --git a/compose.yaml b/compose.yaml index 6e370a4b..c6c640e9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -54,9 +54,11 @@ services: condition: service_started divviup_api: - image: ${DIVVIUP_API_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api:0.3.12} + image: ${DIVVIUP_API_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api_integration_test:0.3.12} ports: - "8080:8080" + healthcheck: + test: ["CMD", "/bin/sh", "-c", "wget http://0.0.0.0:8080/health -O - >/dev/null"] environment: RUST_LOG: info AUTH_URL: https://auth.example