Skip to content

Commit e6a29ba

Browse files
authored
Improve slim build and publish additional -slim images (#19)
1 parent 4c65f8f commit e6a29ba

2 files changed

Lines changed: 48 additions & 26 deletions

File tree

.github/workflows/postgresql.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,22 @@ jobs:
102102
--no-cache-filter trimmed-all \
103103
$TAG .
104104
105-
# - name: Install slim toolkit
106-
# run: |
107-
# curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
108-
#
109-
# - name: Slim the image
110-
# run: |
111-
# # Extract image name from TAG (remove -t prefix)
112-
# IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
113-
# chmod +x ./slim-image.sh
114-
# ./slim-image.sh "$IMAGE_NAME" "${IMAGE_NAME}-slim" amd64
115-
# # Replace original with slim version
116-
# docker tag ${IMAGE_NAME}-slim $IMAGE_NAME
117-
#
105+
- name: Install slim toolkit
106+
run: |
107+
curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
108+
109+
- name: Slim the image
110+
run: |
111+
# Extract image name from TAG (remove -t prefix)
112+
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
113+
chmod +x ./slim-image.sh
114+
./slim-image.sh "$IMAGE_NAME" "${IMAGE_NAME}-slim" amd64
115+
118116
- name: Push amd64 image
119117
run: |
120118
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
121119
docker push $IMAGE_NAME
120+
docker push ${IMAGE_NAME}-slim
122121
123122
image_postgresql_arm64:
124123
needs: image_postgresql_amd64
@@ -203,19 +202,18 @@ jobs:
203202
run: |
204203
curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
205204
206-
# - name: Slim the image
207-
# run: |
208-
# # Extract image name from TAG (remove -t prefix)
209-
# IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
210-
# chmod +x ./slim-image.sh
211-
# ./slim-image.sh "$IMAGE_NAME" "${IMAGE_NAME}-slim" arm64
212-
# # Replace original with slim version
213-
# docker tag ${IMAGE_NAME}-slim $IMAGE_NAME
205+
- name: Slim the image
206+
run: |
207+
# Extract image name from TAG (remove -t prefix)
208+
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
209+
chmod +x ./slim-image.sh
210+
./slim-image.sh "$IMAGE_NAME" "${IMAGE_NAME}-slim" arm64
214211
215212
- name: Push arm64 image
216213
run: |
217214
IMAGE_NAME=$(echo "$TAG" | sed 's/-t //')
218215
docker push $IMAGE_NAME
216+
docker push ${IMAGE_NAME}-slim
219217
220218
create_manifest:
221219
needs: [image_postgresql_amd64, image_postgresql_arm64]
@@ -228,11 +226,18 @@ jobs:
228226
echo "TAG=openremote/postgresql:develop" >> $GITHUB_ENV
229227
echo "TAG_AMD64=openremote/postgresql:develop-amd64" >> $GITHUB_ENV
230228
echo "TAG_ARM64=openremote/postgresql:develop-arm64" >> $GITHUB_ENV
229+
echo "TAG_SLIM=openremote/postgresql:develop-slim" >> $GITHUB_ENV
230+
echo "TAG_SLIM_AMD64=openremote/postgresql:develop-slim-amd64" >> $GITHUB_ENV
231+
echo "TAG_SLIM_ARM64=openremote/postgresql:develop-slim-arm64" >> $GITHUB_ENV
231232
else
232233
echo "TAG=openremote/postgresql:$TAG" >> $GITHUB_ENV
233234
echo "TAG_LATEST=openremote/postgresql:latest" >> $GITHUB_ENV
234235
echo "TAG_AMD64=openremote/postgresql:$TAG-amd64" >> $GITHUB_ENV
235236
echo "TAG_ARM64=openremote/postgresql:$TAG-arm64" >> $GITHUB_ENV
237+
echo "TAG_SLIM=openremote/postgresql:$TAG-slim" >> $GITHUB_ENV
238+
echo "TAG_SLIM_LATEST=openremote/postgresql:latest-slim" >> $GITHUB_ENV
239+
echo "TAG_SLIM_AMD64=openremote/postgresql:$TAG-slim-amd64" >> $GITHUB_ENV
240+
echo "TAG_SLIM_ARM64=openremote/postgresql:$TAG-slim-arm64" >> $GITHUB_ENV
236241
fi
237242
env:
238243
TAG: ${{ github.event.release.tag_name }}
@@ -249,3 +254,10 @@ jobs:
249254
if [ ! -z "$TAG_LATEST" ]; then
250255
docker buildx imagetools create -t $TAG_LATEST $TAG_AMD64 $TAG_ARM64
251256
fi
257+
258+
- name: Create and push multi-arch manifest for slim images
259+
run: |
260+
docker buildx imagetools create -t $TAG_SLIM $TAG_SLIM_AMD64 $TAG_SLIM_ARM64
261+
if [ ! -z "$TAG_SLIM_LATEST" ]; then
262+
docker buildx imagetools create -t $TAG_SLIM_LATEST $TAG_SLIM_AMD64 $TAG_SLIM_ARM64
263+
fi

slim-image.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ echo "Slimming image: $SOURCE_IMAGE -> $TARGET_IMAGE (arch: $ARCH, lib: $LIB_ARC
4444
slim build --target "$SOURCE_IMAGE" \
4545
--tag "$TARGET_IMAGE" \
4646
--http-probe=false \
47-
--continue-after=15 \
47+
--continue-after=60 \
4848
--mount slim-pgdata:/var/lib/postgresql/data \
4949
--expose=5432 \
5050
--expose=8008 \
@@ -55,10 +55,10 @@ slim build --target "$SOURCE_IMAGE" \
5555
--include-path=/usr/share/postgresql-common \
5656
--include-path=/usr/share/proj \
5757
--include-path=/usr/share/gdal \
58-
--include-path=/usr/share/pgbouncer \
59-
--include-path=/usr/share/locales \
58+
--include-path=/usr/share/pgbouncer \
59+
--include-path=/usr/share/locales \
6060
--include-path=/etc/alternatives \
61-
--include-path=/usr/local/bin \
61+
--include-path=/usr/local/bin \
6262
--preserve-path=/var/lib/postgresql \
6363
--preserve-path=/docker-entrypoint-initdb.d \
6464
--preserve-path=/or-entrypoint.sh \
@@ -89,7 +89,17 @@ slim build --target "$SOURCE_IMAGE" \
8989
--include-bin=/bin/cp \
9090
--include-bin=/bin/touch \
9191
--include-bin=/usr/bin/id \
92-
--include-bin=/usr/bin/env
92+
--include-bin=/usr/bin/env \
93+
--include-bin=/bin/sleep \
94+
--include-bin=/usr/bin/ls \
95+
--include-bin=/usr/bin/test \
96+
--include-bin=/usr/bin/psql \
97+
--include-bin=/usr/bin/pg_isready \
98+
--include-bin=/usr/bin/locale \
99+
--include-bin=/usr/bin/localedef \
100+
--include-bin=/usr/bin/less \
101+
--include-bin=/bin/ln \
102+
--include-bin=/usr/bin/chown
93103

94104
# delete volume to always start with an empty PGDATA directory
95105
docker volume rm slim-pgdata

0 commit comments

Comments
 (0)