Skip to content

Commit 223f9d8

Browse files
committed
Docker workflow
1 parent e0a42a3 commit 223f9d8

5 files changed

Lines changed: 59 additions & 94 deletions

File tree

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Dockerfiles CI
1+
name: Dockerfiles Quality Check
22

33
on:
44
push:
@@ -35,77 +35,27 @@ jobs:
3535
- name: Validate docker-compose.yml
3636
run: docker compose -f docker-compose.yml config -q
3737

38-
build-and-test:
39-
name: Build & smoke tests
38+
build-and-sequential-smoke:
39+
name: Build & sequential smoke
4040
runs-on: self-hosted # ubuntu-latest
4141
needs: lint-dockerfiles
42-
strategy:
43-
matrix:
44-
include:
45-
- name: api
46-
dockerfile: Dockerfile.api
47-
context: .
48-
- name: nginx
49-
dockerfile: Dockerfile.nginx
50-
context: .
42+
5143
steps:
5244
- name: Checkout
5345
uses: actions/checkout@v4
5446

5547
- name: Set up Docker Buildx
5648
uses: docker/setup-buildx-action@v3
5749

58-
- name: Build image (${{ matrix.name }})
50+
- name: Build API image
5951
uses: docker/build-push-action@v6
6052
with:
61-
context: ${{ matrix.context }}
62-
file: ${{ matrix.dockerfile }}
63-
tags: local/${{ matrix.name }}:ci-${{ github.sha }}
53+
context: .
54+
file: Dockerfile.api
55+
tags: local/api:ci-${{ github.sha }}
6456
load: true
6557
push: false
6658
provenance: false
6759
sbom: false
68-
cache-from: type=registry,ref=local/${{ matrix.name }}:buildcache
69-
cache-to: type=inline
70-
71-
- name: Run NGINX container (smoke test)
72-
if: matrix.name == 'nginx'
73-
run: |
74-
set -euo pipefail
75-
CONTAINER_NAME=nginx-smoke-${GITHUB_RUN_ID}
76-
docker run -d --rm --name "$CONTAINER_NAME" -p 8080:80 local/nginx:ci-${GITHUB_SHA}
77-
78-
for i in {1..30}; do
79-
STATUS=$(docker inspect --format='{{json .State.Health.Status}}' "$CONTAINER_NAME" | tr -d '"')
80-
if [ "$STATUS" = "healthy" ]; then
81-
echo "Container is healthy."
82-
break
83-
fi
84-
sleep 2
85-
done
86-
87-
STATUS=$(docker inspect --format='{{json .State.Health.Status}}' "$CONTAINER_NAME" | tr -d '"')
88-
if [ "$STATUS" != "healthy" ]; then
89-
echo "::error::Container did not become healthy. Status=$STATUS"
90-
docker logs "$CONTAINER_NAME" || true
91-
docker inspect "$CONTAINER_NAME" || true
92-
exit 1
93-
fi
94-
95-
curl -fsS http://localhost:8080/ >/dev/null
96-
97-
docker kill "$CONTAINER_NAME" >/dev/null
98-
99-
- name: Run API container (smoke run)
100-
if: matrix.name == 'api'
101-
run: |
102-
set -euo pipefail
103-
CONTAINER_NAME=api-smoke-${GITHUB_RUN_ID}
104-
docker run -d --rm --name "$CONTAINER_NAME" local/api:ci-${GITHUB_SHA} || (echo "::warning::API container failed to start"; exit 1)
105-
sleep 5
106-
if ! docker ps --filter "name=$CONTAINER_NAME" --format '{{.Names}}' | grep -q "$CONTAINER_NAME"; then
107-
echo "::error::API container is not running after 5s."
108-
docker logs "$CONTAINER_NAME" || true
109-
exit 1
110-
fi
111-
docker kill "$CONTAINER_NAME" >/dev/null
60+
cache-from: type=gha,scope=api
61+
cache-to: type=gha,mode=max,scope=api

Dockerfile.api

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
FROM python:3.12-slim-bookworm AS base
22

3-
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
ca-certificates \
5-
build-essential \
6-
libpq-dev \
7-
gcc \
8-
curl \
9-
&& rm -rf /var/lib/apt/lists/*
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
ARG APT_CA_CERTS_VER=20230311+deb12u1
5+
ARG APT_BUILD_ESSENTIAL_VER=12.9
6+
ARG APT_LIBPQ_DEV_VER=15.14-0+deb12u1
7+
ARG APT_GCC_VER=4:12.2.0-3
8+
ARG APT_CURL_VER=7.88.1-10+deb12u14
9+
10+
ARG PIP_VERSION=25.0.1
1011

1112
ENV PYTHONDONTWRITEBYTECODE=1 \
1213
PYTHONUNBUFFERED=1 \
13-
PIP_NO_CACHE_DIR=1 \
14-
DEBIAN_FRONTEND=noninteractive
14+
PIP_NO_CACHE_DIR=1
15+
16+
RUN apt-get update && apt-get install -y --no-install-recommends \
17+
ca-certificates=${APT_CA_CERTS_VER} \
18+
build-essential=${APT_BUILD_ESSENTIAL_VER} \
19+
libpq-dev=${APT_LIBPQ_DEV_VER} \
20+
gcc=${APT_GCC_VER} \
21+
curl=${APT_CURL_VER} \
22+
&& rm -rf /var/lib/apt/lists/*
1523

1624
WORKDIR /app
1725

1826
COPY requirements.txt /app/requirements.txt
19-
RUN pip install --upgrade pip && pip install -r /app/requirements.txt
27+
28+
RUN python -m pip install --upgrade "pip==${PIP_VERSION}" \
29+
&& pip install --no-cache-dir --requirement /app/requirements.txt
2030

2131
COPY . /app
2232

requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
pandas
2-
openpyxl
3-
numpy
4-
pymoo
5-
pydantic-settings
6-
psycopg
7-
flask
8-
flask-cors
9-
gunicorn
1+
pandas==2.2.3
2+
openpyxl==3.1.5
3+
numpy==1.26.4
4+
pymoo==0.6.1.5
5+
pydantic-settings==2.10.1
6+
psycopg==3.2.9
7+
flask==3.1.2
8+
flask-cors==6.0.1
9+
gunicorn==23.0.0

tests/requirements-dev.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
pytest
2-
hypothesis
3-
pytest-cov
4-
pytest-html
5-
pylint
1+
pytest==8.3.5
2+
hypothesis==6.138.3
3+
pytest-cov==7.0.0
4+
pytest-html==4.1.1
5+
pylint==3.3.8
66

7-
pandas
8-
openpyxl
9-
numpy
10-
pymoo
11-
pydantic-settings
12-
psycopg
13-
flask
14-
flask-cors
15-
gunicorn
7+
pandas==2.2.3
8+
openpyxl==3.1.5
9+
numpy==1.26.4
10+
pymoo==0.6.1.5
11+
pydantic-settings==2.10.1
12+
psycopg==3.2.9
13+
flask==3.1.2
14+
flask-cors==6.0.1
15+
gunicorn==23.0.0

web/api/routes/health_routes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
health_bp = Blueprint('health', __name__, url_prefix='/api')
99

1010

11+
@health_bp.route('/ready', methods=['GET'])
12+
def ready_check():
13+
return jsonify(status="ok"), 200
14+
15+
1116
@health_bp.route('/health', methods=['GET'])
1217
def health_check():
13-
"""Health check endpoint."""
18+
"""Health deep endpoint check."""
1419
try:
1520
staff_service.get_all_staff()
1621
return jsonify({

0 commit comments

Comments
 (0)