Skip to content

Commit

Permalink
Add healthcheck for divviup-api to compose.yaml (#1097)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tgeoghegan committed Jun 13, 2024
1 parent b189dbd commit 5d3c317
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,43 @@ 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 }}
cache-to: type=gha,scope=${{ github.ref_name }}-${{ matrix.rust-features }},mode=max
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
4 changes: 3 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5d3c317

Please sign in to comment.