Skip to content

Commit 43966a6

Browse files
committed
docker: Slim down run image to save space for github
Those changes were motivated to github This extra clean step saves 3GB (11GB to 7.6GB, which is still huge) Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#10 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#15 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#7 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#2 Forwarded: SiliconLabsSoftware#83 Signed-off-by: Philippe Coval <[email protected]>
1 parent 28fb9d1 commit 43966a6

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@ jobs:
2323
| tee $GITHUB_OUTPUT
2424
- name: Build Docker image from sources
2525
run: >-
26+
df -h
27+
&&
2628
docker build
2729
--tag "${{ env.project-name }}:latest"
2830
--build-arg UNIFYSDK_GIT_REPOSITORY=${{ secrets.UNIFYSDK_GIT_REPOSITORY }}
2931
--build-arg UNIFYSDK_GIT_TAG=${{ secrets.UNIFYSDK_GIT_TAG }}
3032
.
33+
&&
34+
df -h
35+
3136
- name: Extract artifacts
3237
run: >-
3338
container=$(docker create "${{ env.project-name }}:latest")
3439
&& docker cp
35-
${container}:/usr/local/opt/${{ env.project-name }}/build/dist .
40+
${container}:/usr/local/opt/${{ env.project-name }}/dist .
3641
- name: Upload artifacts
3742
uses: actions/upload-artifact@v4
3843
with:

Dockerfile

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:bookworm
1+
FROM debian:bookworm as builder
22

33
ENV DEBIAN_FRONTEND noninteractive
44
ENV LC_ALL en_US.UTF-8
@@ -25,20 +25,37 @@ WORKDIR ${workdir}
2525

2626
RUN echo "# log: Setup system" \
2727
&& set -x \
28+
&& df -h \
2829
&& apt-get install -y make sudo \
2930
&& ./helper.mk help setup \
3031
&& date -u
3132

3233
RUN echo "# log: Build" \
3334
&& set -x \
3435
&& ./helper.mk \
36+
&& date -u \
37+
&& echo "# log: Clean to only keep packages to save space" \
38+
&& mkdir -p dist \
39+
&& cd dist \
40+
&& unzip ../build/dist/${project}*.zip \
41+
&& cd - \
42+
&& ./helper.mk distclean \
3543
&& date -u
3644

45+
FROM debian:bookworm
46+
ENV project z-wave-protocol-controller
47+
ENV workdir /usr/local/opt/${project}
48+
COPY --from=builder ${workdir}/dist/ ${workdir}/dist/
49+
WORKDIR ${workdir}
50+
3751
RUN echo "# log: Install to system" \
3852
&& set -x \
39-
&& sudo dpkg -i ./build/${project}_*/*.deb \
40-
|| sudo apt install -f \
41-
&& sudo apt-get install -y mosquitto \
53+
&& apt-get update \
54+
&& dpkg -i ./dist/${project}*/*.deb \
55+
|| apt install -f -y \
56+
&& apt-get install -y mosquitto \
57+
&& apt-get clean -y \
58+
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
4259
&& date -u
4360

4461
ENTRYPOINT [ "/usr/bin/zpc" ]

0 commit comments

Comments
 (0)