Skip to content

Commit 28c65d7

Browse files
author
Laudin Molina Troconis
committed
chore(ci): split Dockerfile into dev/builder/runtime stages
Rebuilding the full image on every code change is slow. A reusable dev stage lets you iterate on build/test/develop without repeating setup. The project is not building when using Debian Trixie, therefore the dev container is useful to use Debian Bookworm.
1 parent 0063214 commit 28c65d7

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
# SPDX-License-Identifier: Zlib
22
# SPDX-FileCopyrightText: Silicon Laboratories Inc. https://www.silabs.com
33

4-
FROM debian:bookworm AS builder
4+
# Development stage: setup only (no build). Use with:
5+
# docker build --target dev -t z-wave-protocol-controller:dev .
6+
FROM debian:bookworm AS dev
57

6-
ARG UNIFYSDK_GIT_REPOSITORY https://github.com/SiliconLabs/UnifySDK
7-
ARG UNIFYSDK_GIT_TAG main
8+
ARG UNIFYSDK_GIT_REPOSITORY=https://github.com/SiliconLabs/UnifySDK
9+
ARG UNIFYSDK_GIT_TAG=main
10+
ENV UNIFYSDK_GIT_REPOSITORY=${UNIFYSDK_GIT_REPOSITORY} \
11+
UNIFYSDK_GIT_TAG=${UNIFYSDK_GIT_TAG}
812

913
ENV project z-wave-protocol-controller
1014
ENV workdir /usr/local/opt/${project}
1115

12-
ADD . ${workdir}
1316
ARG HELPER="./helper.mk"
1417
ARG HELPER_SETUP_RULES=setup
1518
ARG HELPER_DEFAULT_RULES=default
19+
ENV HELPER=${HELPER} \
20+
HELPER_DEFAULT_RULES=${HELPER_DEFAULT_RULES}
1621

1722
WORKDIR ${workdir}
18-
23+
ADD . ${workdir}
1924
RUN echo "# log: Setup system" \
2025
&& set -x \
2126
&& df -h \
2227
&& apt-get update \
2328
&& apt-get install -y --no-install-recommends -- make sudo \
24-
&& ${HELPER} help ${HELPER_SETUP_RULES} \
29+
&& ${HELPER} ${HELPER_SETUP_RULES} \
2530
&& date -u
31+
ENTRYPOINT [ "/usr/bin/bash" ]
32+
CMD []
2633

34+
FROM dev AS builder
2735
RUN echo "# log: Build" \
2836
&& set -x \
2937
&& ${HELPER} ${HELPER_DEFAULT_RULES} \
@@ -36,7 +44,8 @@ RUN echo "# log: Build" \
3644
&& ${HELPER} distclean \
3745
&& date -u
3846

39-
FROM debian:bookworm
47+
# Default image for CI and docker-compose (build with no --target).
48+
FROM debian:bookworm AS runtime
4049
ENV project=z-wave-protocol-controller
4150
ARG workdir=/usr/local/opt/${project}
4251
COPY --from=builder ${workdir}/dist/ ${workdir}/dist/

0 commit comments

Comments
 (0)