|
1 | | -name: Dockerfiles CI |
| 1 | +name: Dockerfiles Quality Check |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
@@ -35,77 +35,27 @@ jobs: |
35 | 35 | - name: Validate docker-compose.yml |
36 | 36 | run: docker compose -f docker-compose.yml config -q |
37 | 37 |
|
38 | | - build-and-test: |
39 | | - name: Build & smoke tests |
| 38 | + build-and-sequential-smoke: |
| 39 | + name: Build & sequential smoke |
40 | 40 | runs-on: self-hosted # ubuntu-latest |
41 | 41 | 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 | + |
51 | 43 | steps: |
52 | 44 | - name: Checkout |
53 | 45 | uses: actions/checkout@v4 |
54 | 46 |
|
55 | 47 | - name: Set up Docker Buildx |
56 | 48 | uses: docker/setup-buildx-action@v3 |
57 | 49 |
|
58 | | - - name: Build image (${{ matrix.name }}) |
| 50 | + - name: Build API image |
59 | 51 | uses: docker/build-push-action@v6 |
60 | 52 | 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 }} |
64 | 56 | load: true |
65 | 57 | push: false |
66 | 58 | provenance: false |
67 | 59 | 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 |
0 commit comments