diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 83cc8d2..19420f9 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -14,8 +14,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Start Docker Compose - run: docker compose up -d + - name: Docker Build + run: docker compose build - - name: Check /health endpoint returns 200 - run: curl -fs 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..8f82467 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: 3s + timeout: 10s + retries: 3 + start_period: 2s