Skip to content

Commit fdd18c0

Browse files
committed
feat/docker/add-health-check-endpoint
1 parent 3920232 commit fdd18c0

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,15 @@ jobs:
8383
run: |
8484
source .venv/bin/activate
8585
poetry run python tasks/format.py --dry-run
86+
87+
- name: Start Docker Compose
88+
run: |
89+
docker compose up -d
90+
91+
- name: Install test dependencies
92+
run: |
93+
docker exec flask_api poetry install --with test
94+
95+
- name: Run tests in container
96+
run: |
97+
docker exec flask_api poetry run pytest -rfsxE --capture=no --log-cli-level=DEBUG --maxfail=1 ./test

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ services:
1010
command: python ./src/server.py
1111
volumes:
1212
- ./:/app:rw
13+
healthcheck:
14+
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
15+
interval: 5s
16+
timeout: 3s
17+
retries: 60
18+
start_period: 5s

src/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
88

99

10+
@app.route("/health", methods=["GET"])
11+
def health():
12+
return jsonify({"status": "ok"}), 200
13+
14+
1015
@app.route("/doc_to_pdf", methods=["GET", "POST"])
1116
def upload_file():
1217
if request.method == "GET":

0 commit comments

Comments
 (0)