-
Notifications
You must be signed in to change notification settings - Fork 3.6k
153 lines (136 loc) · 4.49 KB
/
docker-dryrun.yml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build and Health Check Docker Images
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
Build:
strategy:
matrix:
image: ['s-pdf:standard', 's-pdf:standard with auth', 's-pdf:ultra-lite', 's-pdf:ultra-lite with auth', 's-pdf:lite', 's-pdf:lite with auth']
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
- uses: gradle/[email protected]
with:
gradle-version: 7.6
arguments: clean build
- name: Make Gradle wrapper executable
run: chmod +x gradlew
- name: Get version number
id: versionNumber
run: echo "::set-output name=versionNumber::$(./gradlew printVersion --quiet | tail -1)"
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build main Dockerfile
uses: docker/[email protected]
with:
context: .
dockerfile: ./Dockerfile
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: s-pdf:standard
build-args:
VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
platforms: linux/amd64
- name: Build Dockerfile-ultra-lite
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile-ultra-lite
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: s-pdf:ultra-lite
build-args:
VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
platforms: linux/amd64
- name: Build Dockerfile-lite
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile-lite
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: s-pdf:lite
build-args:
VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
platforms: linux/amd64
# - name: Build main Dockerfile
# uses: docker/[email protected]
# with:
# context: .
# dockerfile: ./Dockerfile
# push: false
# cache-from: type=gha
# cache-to: type=gha,mode=max
# tags: s-pdf:standard
# build-args:
# VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
# platforms: linux/arm64
# - name: Build Dockerfile-ultra-lite
# uses: docker/[email protected]
# with:
# context: .
# file: ./Dockerfile-ultra-lite
# push: false
# cache-from: type=gha
# cache-to: type=gha,mode=max
# tags: s-pdf:ultra-lite
# build-args:
# VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
# platforms: linux/arm64
# - name: Build Dockerfile-lite
# uses: docker/[email protected]
# with:
# context: .
# file: ./Dockerfile-lite
# push: false
# cache-from: type=gha
# cache-to: type=gha,mode=max
# tags: s-pdf:lite
# build-args:
# VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
# platforms: linux/arm64
- name: Run and check Docker image ${{ matrix.image }}
run: |
IMAGE=${{ matrix.image }}
AUTH=false
HEALTH_CMD="curl -f http://localhost:8080/api/v1/status | grep -q UP && curl -fL http://localhost:8080/ | grep -qv 'Please sign in'"
if [[ $IMAGE == *"with auth"* ]]; then
AUTH=true
HEALTH_CMD="curl -fL http://localhost:8080/ | grep -q 'Please sign in'"
IMAGE=${IMAGE% with auth}
fi
CONTAINER_ID=$(docker run -d -e DOCKER_ENABLE_SECURITY=$AUTH -e SECURITY_ENABLE_LOGIN=$AUTH --health-cmd="$HEALTH_CMD" --health-interval=5s --health-timeout=5s --health-retries=6 $IMAGE)
for i in {1..12}
do
HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER_ID)
if [ "$HEALTH_STATUS" = "healthy" ]
then
echo "Container is healthy"
docker rm -f $CONTAINER_ID
break
fi
sleep 5
done
if [ "$HEALTH_STATUS" != "healthy" ]
then
exit 1
fi