[v14] oci: Parameterize Debian OCI Dockerfile for multiarch#34188
Merged
camscale merged 2 commits intobranch/v14from Nov 14, 2023
Merged
[v14] oci: Parameterize Debian OCI Dockerfile for multiarch#34188camscale merged 2 commits intobranch/v14from
camscale merged 2 commits intobranch/v14from
Conversation
Parameterize the Debian OCI Dockerfile to take a `.deb` filename without
an architecture so we can use `${TARGETARCH}` in a multi-architecture
build. `${DEB_PATH}` still has precedence, but if not specified,
`${DEB_BASE}` can be provided to specify the `.deb` file to install into
the image without the architecture or `.deb` suffix.
This also fixes the `${DEB_PATH?}` expansion which is not a valid
expansion in a Dockerfile.
With this change, a multi-architecture image can be built with
docker buildx build --platform p1,p2,p3 \
--build-arg DEB_BASE=teleport-ent-v1.2.3 \
...
and docker will set `${TARGETARCH}` to the architecture of each of the
platforms `p1`, `p2` and `p3` as it builds each, having us install the
correct architecture of teleport `.deb` file.
Use `RUN --mount=target-/ctx` to mount the Docker build context to access the `.deb` file to install instead of `COPY`ing it in. This saves space on the image. Separate the installation of the Teleport `.deb` file to come after installing the prerequisites with `apt-get`. This allows that layer to be cached so we can build the OSS and Enterprise images sharing that base. This reduces the network traffic too and the risk of failure due to transient network errors. The build time of a subsequent image is seconds so we don't lose anything due to the removal of potential parallelism.
r0mant
approved these changes
Nov 3, 2023
tcsc
approved these changes
Nov 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parameterize the Debian OCI Dockerfile to take a
.debfilename withoutan architecture so we can use
${TARGETARCH}in a multi-architecturebuild.
${DEB_PATH}still has precedence, but if not specified,${DEB_BASE}can be provided to specify the.debfile to install intothe image without the architecture or
.debsuffix.This also fixes the
${DEB_PATH?}expansion which is not a validexpansion in a Dockerfile.
With this change, a multi-architecture image can be built with
and docker will set
${TARGETARCH}to the architecture of each of theplatforms
p1,p2andp3as it builds each, having us install thecorrect architecture of teleport
.debfile.Issue: #20729
Backport: #33949