From ecac9e1e85eeb0bac28ec17ef7bb57a3335d8443 Mon Sep 17 00:00:00 2001 From: TrymT Date: Sat, 19 Jul 2025 17:21:11 +0200 Subject: [PATCH 1/4] look for docker containers --- .github/workflows/build-and-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 83cc8d2..855d10b 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -17,5 +17,8 @@ jobs: - name: Start Docker Compose run: docker compose up -d + - name: List docker containers + run: docker ps + - name: Check /health endpoint returns 200 - run: curl -fs http://localhost:8080/health + run: curl -f http://localhost:8080/health From b60eda7ca37be7cf67881a9256487b3247feda48 Mon Sep 17 00:00:00 2001 From: TrymT Date: Sat, 19 Jul 2025 17:39:01 +0200 Subject: [PATCH 2/4] add health check and wait for healty in workflow --- .github/workflows/build-and-deploy.yml | 16 +++++++++------- Dockerfile | 1 + docker-compose.yml | 6 ++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 855d10b..27ca13a 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -14,11 +14,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Start Docker Compose - run: docker compose up -d - - - name: List docker containers - run: docker ps + - name: Docker Build + run: docker compose build - - name: Check /health endpoint returns 200 - run: curl -f http://localhost:8080/health + - name: Start Docker Compose + : # start the docker contianer and wait 10 sec for container to be healty + run: docker compose up -d --wait --wait-timeout 10 + + - name: Show Docker logs (on failure) + if: failure() + run: docker compose logs diff --git a/Dockerfile b/Dockerfile index c899239..7b706e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ COPY static ./static COPY templates ./templates COPY backend ./backend RUN pip install -r backend/requirements.txt +RUN apt-get -y update; apt-get -y install curl EXPOSE 8080/tcp ENV ENV_NAME=PROD ENV PYTHONUNBUFFERED=1 diff --git a/docker-compose.yml b/docker-compose.yml index 64769a3..f74c2ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,3 +3,9 @@ services: build: . ports: - "8080:8080" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 5s + timeout: 10s + retries: 3 + start_period: 5s From f89e296b4172aab4de9148b1cec9bf6794f1c265 Mon Sep 17 00:00:00 2001 From: TrymT Date: Sat, 19 Jul 2025 17:39:57 +0200 Subject: [PATCH 3/4] fix workflow comment --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 27ca13a..19420f9 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -18,7 +18,7 @@ jobs: run: docker compose build - name: Start Docker Compose - : # start the docker contianer and wait 10 sec for container to be healty + # start the docker contianer and wait 10 sec for container to be healty run: docker compose up -d --wait --wait-timeout 10 - name: Show Docker logs (on failure) From 099c9adb9a7b43eee6239354a1ad06ab586fb136 Mon Sep 17 00:00:00 2001 From: TrymT Date: Sat, 19 Jul 2025 17:41:44 +0200 Subject: [PATCH 4/4] tune healthecks --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f74c2ec..8f82467 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: - "8080:8080" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] - interval: 5s + interval: 3s timeout: 10s retries: 3 - start_period: 5s + start_period: 2s