Skip to content

Commit

Permalink
ci(docker): smoke test the built image
Browse files Browse the repository at this point in the history
After building the image, this adds a test that it actually runs and reports itself as healthy. This covers that the
HTTP server runs, not that the content inside (specifically the React application) is working.

Refs #390
  • Loading branch information
thewilkybarkid committed Jul 22, 2021
1 parent 6cf476f commit c76d5fd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/smoke-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e

function finish() {
echo "Stopping all containers"
docker-compose logs
docker-compose down
}

trap finish EXIT

export IMAGE_TAG="${IMAGE_TAG:-local}"

docker-compose up --detach
container=prereview

timeout --foreground 20 bash << EOT
while true; do
current=\$(docker inspect "${container}" | jq -r '.[0].State.Health.Status')
echo "${container} is in state: \${current}"
if [ "\$current" == "healthy" ]; then
break
fi
sleep 1
done
EOT
3 changes: 3 additions & 0 deletions .github/workflows/deploy_prereview-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: 'Build image'
run: docker-compose build prereview

- name: 'Smoke test'
run: .github/smoke-test.sh

- name: 'Tag image'
run: docker tag prereview.azurecr.io/prereview:${IMAGE_TAG} prereview.azurecr.io/prereview:develop

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/deploy_prereview-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: 'Build image'
run: docker-compose build prereview

- name: 'Smoke test'
run: .github/smoke-test.sh

- name: 'Tag image'
run: docker tag prereview.azurecr.io/prereview:${IMAGE_TAG} prereview.azurecr.io/prereview:latest

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "3"
services:
prereview:
container_name: prereview
image: prereview.azurecr.io/prereview:${IMAGE_TAG:-local}
build: .
depends_on:
Expand Down

0 comments on commit c76d5fd

Please sign in to comment.