-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (77 loc) · 2.78 KB
/
Copy pathdocker.yml
File metadata and controls
94 lines (77 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: 🐋 Docker Validation
run-name: 🐋 Container Validation • ${{ github.ref_name }}
on:
push:
branches:
- main
- develop
- dev
pull_request:
branches:
- main
- develop
- dev
workflow_dispatch:
permissions:
contents: read
jobs:
validate:
name: 🐋 Validate Development and Production Images
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
- name: 🐋 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: ✅ Build validation stage
uses: docker/build-push-action@v6
with:
context: .
target: validation
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
- name: 🏗️ Build production-preview image
uses: docker/build-push-action@v6
with:
context: .
target: production
load: true
push: false
tags: devalltect00-docs-prod:ci
cache-from: type=gha
- name: 🚀 Start production-preview image
id: preview
run: |
container_id="$(docker run --detach --publish 8080:8080 devalltect00-docs-prod:ci)"
echo "container_id=$container_id" >> "$GITHUB_OUTPUT"
- name: 🔎 Smoke-test static site
run: |
container_id="${{ steps.preview.outputs.container_id }}"
for attempt in $(seq 1 60); do
container_status="$(docker inspect --format='{{.State.Status}}' "$container_id")"
health_status="$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}unavailable{{end}}' "$container_id")"
if [ "$health_status" = "healthy" ]; then
break
fi
if [ "$container_status" != "running" ] || [ "$health_status" = "unhealthy" ]; then
echo "Container failed before the smoke test completed."
docker logs "$container_id"
docker inspect "$container_id"
exit 1
fi
if [ "$attempt" -eq 60 ]; then
echo "Timed out waiting for the container to become healthy."
docker logs "$container_id"
docker inspect "$container_id"
exit 1
fi
sleep 1
done
curl --fail --show-error --silent --retry 5 --retry-delay 1 --retry-all-errors \
http://127.0.0.1:8080/healthz
curl --fail --show-error --silent --retry 5 --retry-delay 1 --retry-all-errors \
http://127.0.0.1:8080/devalltect-docs/
- name: 🧹 Stop production-preview image
if: always() && steps.preview.outputs.container_id != ''
run: docker rm --force "${{ steps.preview.outputs.container_id }}"