-
Notifications
You must be signed in to change notification settings - Fork 3
263 lines (221 loc) · 9.15 KB
/
postgresql.yml
File metadata and controls
263 lines (221 loc) · 9.15 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# This is a basic workflow to help you get started with Actions
name: Docker Image
# Controls when the action will run.
on:
# When a release is published
release:
types: [published]
# Push excluding tags and workflow changes
push:
branches:
- main
tags-ignore:
- '*.*'
paths-ignore:
- '**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
image_postgresql_amd64:
runs-on: ubuntu-latest
steps:
- name: Free up disk space
run: |
echo "Disk space before cleanup:"
df -h
# Remove large directories
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
# Remove large packages
sudo apt-get remove -y '^aspnetcore-.*' || true
sudo apt-get remove -y '^dotnet-.*' || true
sudo apt-get remove -y '^llvm-.*' || true
sudo apt-get remove -y 'php.*' || true
sudo apt-get remove -y '^mongodb-.*' || true
sudo apt-get remove -y '^mysql-.*' || true
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
sudo apt-get remove -y google-cloud-sdk google-cloud-cli || true
sudo apt-get autoremove -y
sudo apt-get clean
# Remove Docker images
sudo docker image prune --all --force
# Remove swap storage
sudo swapoff -a || true
sudo rm -f /mnt/swapfile || true
echo "Disk space after cleanup:"
df -h
- name: Set tags
run: |
if [ -z "$TAG" ]; then
echo "TAG=-t openremote/postgresql:develop-amd64" >> $GITHUB_ENV
else
echo "TAG=-t openremote/postgresql:$TAG-amd64" >> $GITHUB_ENV
fi
env:
TAG: ${{ github.event.release.tag_name }}
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
with:
platforms: all
- name: install buildx
id: buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
with:
version: latest
install: true
- name: Login to DockerHub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
with:
username: ${{ secrets._TEMP_DOCKERHUB_USER }}
password: ${{ secrets._TEMP_DOCKERHUB_PASSWORD }}
- name: Build amd64 image locally
run: |
docker buildx build \
--build-arg GIT_COMMIT=${{ github.sha }} \
--load \
--platform linux/amd64 \
--no-cache-filter trimmed \
--no-cache-filter trimmed-all \
$TAG .
- name: Install slim toolkit
run: |
curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
- name: Slim the image
run: |
# Extract image name from TAG (remove -t prefix)
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
chmod +x ./slim-image.sh
./slim-image.sh "$IMAGE_NAME" "${IMAGE_NAME}-slim" amd64
- name: Push amd64 image
run: |
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
docker push $IMAGE_NAME
docker push ${IMAGE_NAME}-slim
image_postgresql_arm64:
needs: image_postgresql_amd64
runs-on: ubuntu-latest
steps:
- name: Free up disk space
run: |
echo "Disk space before cleanup:"
df -h
# Remove large directories
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /opt/hostedtoolcache/CodeQL
# Remove large packages
sudo apt-get remove -y '^aspnetcore-.*' || true
sudo apt-get remove -y '^dotnet-.*' || true
sudo apt-get remove -y '^llvm-.*' || true
sudo apt-get remove -y 'php.*' || true
sudo apt-get remove -y '^mongodb-.*' || true
sudo apt-get remove -y '^mysql-.*' || true
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri || true
sudo apt-get remove -y google-cloud-sdk google-cloud-cli || true
sudo apt-get autoremove -y
sudo apt-get clean
# Remove Docker images
sudo docker image prune --all --force
# Remove swap storage
sudo swapoff -a || true
sudo rm -f /mnt/swapfile || true
echo "Disk space after cleanup:"
df -h
- name: Set tags
run: |
if [ -z "$TAG" ]; then
echo "TAG=-t openremote/postgresql:develop-arm64" >> $GITHUB_ENV
else
echo "TAG=-t openremote/postgresql:$TAG-arm64" >> $GITHUB_ENV
fi
env:
TAG: ${{ github.event.release.tag_name }}
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- name: set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
with:
platforms: all
- name: install buildx
id: buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
with:
version: latest
install: true
- name: Login to DockerHub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
with:
username: ${{ secrets._TEMP_DOCKERHUB_USER }}
password: ${{ secrets._TEMP_DOCKERHUB_PASSWORD }}
- name: Build arm64 image locally
run: |
docker buildx build \
--build-arg GIT_COMMIT=${{ github.sha }} \
--load \
--platform linux/arm64 \
--no-cache-filter trimmed \
--no-cache-filter trimmed-all \
$TAG .
- name: Install slim toolkit
run: |
curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
- name: Slim the image
run: |
# Extract image name from TAG (remove -t prefix)
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
chmod +x ./slim-image.sh
./slim-image.sh "$IMAGE_NAME" "${IMAGE_NAME}-slim" arm64
- name: Push arm64 image
run: |
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
docker push $IMAGE_NAME
docker push ${IMAGE_NAME}-slim
create_manifest:
needs: [image_postgresql_amd64, image_postgresql_arm64]
runs-on: ubuntu-latest
steps:
- name: Set tags
run: |
if [ -z "$TAG" ]; then
echo "TAG=openremote/postgresql:develop" >> $GITHUB_ENV
echo "TAG_AMD64=openremote/postgresql:develop-amd64" >> $GITHUB_ENV
echo "TAG_ARM64=openremote/postgresql:develop-arm64" >> $GITHUB_ENV
echo "TAG_SLIM=openremote/postgresql:develop-slim" >> $GITHUB_ENV
echo "TAG_SLIM_AMD64=openremote/postgresql:develop-slim-amd64" >> $GITHUB_ENV
echo "TAG_SLIM_ARM64=openremote/postgresql:develop-slim-arm64" >> $GITHUB_ENV
else
echo "TAG=openremote/postgresql:$TAG" >> $GITHUB_ENV
echo "TAG_LATEST=openremote/postgresql:latest" >> $GITHUB_ENV
echo "TAG_AMD64=openremote/postgresql:$TAG-amd64" >> $GITHUB_ENV
echo "TAG_ARM64=openremote/postgresql:$TAG-arm64" >> $GITHUB_ENV
echo "TAG_SLIM=openremote/postgresql:$TAG-slim" >> $GITHUB_ENV
echo "TAG_SLIM_LATEST=openremote/postgresql:latest-slim" >> $GITHUB_ENV
echo "TAG_SLIM_AMD64=openremote/postgresql:$TAG-slim-amd64" >> $GITHUB_ENV
echo "TAG_SLIM_ARM64=openremote/postgresql:$TAG-slim-arm64" >> $GITHUB_ENV
fi
env:
TAG: ${{ github.event.release.tag_name }}
- name: Login to DockerHub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
with:
username: ${{ secrets._TEMP_DOCKERHUB_USER }}
password: ${{ secrets._TEMP_DOCKERHUB_PASSWORD }}
- name: Create and push multi-arch manifest
run: |
docker buildx imagetools create -t $TAG $TAG_AMD64 $TAG_ARM64
if [ ! -z "$TAG_LATEST" ]; then
docker buildx imagetools create -t $TAG_LATEST $TAG_AMD64 $TAG_ARM64
fi
- name: Create and push multi-arch manifest for slim images
run: |
docker buildx imagetools create -t $TAG_SLIM $TAG_SLIM_AMD64 $TAG_SLIM_ARM64
if [ ! -z "$TAG_SLIM_LATEST" ]; then
docker buildx imagetools create -t $TAG_SLIM_LATEST $TAG_SLIM_AMD64 $TAG_SLIM_ARM64
fi