Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add healthcheck for divviup-api to compose.yaml #1097

Merged
merged 10 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ jobs:
build-args: |
GIT_REVISION=${{ steps.git.outputs.GIT_REVISION }}
RUST_FEATURES=${{ matrix.rust-features }}
- name: Compose
id: compose
run: docker compose up --wait --wait-timeout 120
# continue on error so we can inspect containers in the next step
continue-on-error: true
- name: Inspect containers
if: steps.compose.outcome != 'success'
run: |
docker compose ps
for NAME in `docker compose ps --format json | jq -r '.Name'`; do
docker inspect $NAME
done
exit 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could simplify this by replacing the default if: success() condition on the last step, and getting rid of continue-on-error: true. See https://docs.github.com/en/actions/learn-github-actions/expressions#example-of-failure-with-conditions.

Suggested change
# continue on error so we can inspect containers in the next step
continue-on-error: true
- name: Inspect containers
if: steps.compose.outcome != 'success'
run: |
docker compose ps
for NAME in `docker compose ps --format json | jq -r '.Name'`; do
docker inspect $NAME
done
exit 1
- 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool, I wasn't aware of this advance in the state of the art of encoding program logic as YAML

2 changes: 2 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ services:
image: ${DIVVIUP_API_IMAGE:-us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/divviup_api: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
Loading