Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# ignore everything
*
# use exceptions to create an "allow list"
!/config
!/src
!/asgi.py
!/bin
!/config
!/poetry.lock
!/pyproject.toml
!/version.json
!/src
!/version.json
28 changes: 28 additions & 0 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
jobs:
build-and-publish:
runs-on: ubuntu-latest
env:
TEST_TAG: ${{ github.repository }}:test
TEST_CONTAINER_NAME: jbi-healthcheck
steps:
- name: Check out the repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -43,6 +46,31 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
load: true
push: false
tags: ${{ env.TEST_TAG }}

- name: Spin up container
run: |
docker run \
--name ${{ env.TEST_CONTAINER_NAME }} \
--detach \
--env-file .env.example \
--publish 8000:8000 \
${{ env.TEST_TAG }}

- name: Check that container is running
run: |
docker exec ${{ env.TEST_CONTAINER_NAME }} python bin/healthcheck.py

- name: Spin down container
run: |
docker rm -f ${{ env.TEST_CONTAINER_NAME }}

- name: Build and push
uses: docker/build-push-action@v3
with:
Expand Down
16 changes: 16 additions & 0 deletions bin/healthcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python

import os

import requests
from requests.adapters import HTTPAdapter, Retry

PORT = os.environ["PORT"]

session = requests.Session()

retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504])
session.mount("http://", HTTPAdapter(max_retries=retries))
if __name__ == "__main__":
response = session.get(f"http://0.0.0.0:{PORT}/")
response.raise_for_status()