-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create multi-arch container images by first cross compiling the binaries for the different platforms, and then creating the container images by copying the binaries.
- Loading branch information
Showing
4 changed files
with
96 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[target.x86_64-unknown-linux-musl] | ||
linker = "x86_64-linux-musl-ld" | ||
ar = "x86_64-linux-musl-ar" | ||
|
||
[target.aarch64-unknown-linux-musl] | ||
linker = "aarch64-linux-musl-ld" | ||
ar = "aarch64-linux-musl-ar" |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
# build image | ||
FROM registry.opensuse.org/opensuse/leap:15.3 as builder | ||
|
||
RUN zypper in -y curl && \ | ||
sh -c 'curl https://download.opensuse.org/repositories/devel:/languages:/rust/openSUSE_Leap_15.3/repodata/repomd.xml.key > gpg.key' && \ | ||
gpg --import gpg.key && \ | ||
rpm --import gpg.key && \ | ||
# Now add the repository and install cargo | ||
zypper ar -f obs://devel:languages:rust/openSUSE_Leap_15.3 devel:languages:rust && \ | ||
zypper ref && \ | ||
zypper in -y gcc cargo | ||
|
||
WORKDIR /usr/src/policy-server | ||
COPY . . | ||
RUN cargo install --root /usr/local/cargo --path . | ||
|
||
# final image | ||
FROM registry.suse.com/bci/minimal | ||
LABEL org.opencontainers.image.source https://github.com/kubewarden/policy-server | ||
|
||
# By default we will run as this user... | ||
FROM alpine AS common | ||
RUN echo "policy-server:x:65533:65533::/tmp:/sbin/nologin" >> /etc/passwd | ||
# Add the default GID to /etc/group for completeness. | ||
RUN echo "policy-server:x:65533:policy-server" >> /etc/group | ||
|
||
COPY --from=builder /usr/local/cargo/bin/policy-server /usr/local/bin/policy-server | ||
# amd64-specific | ||
FROM scratch AS build-amd64 | ||
COPY --from=common /etc/passwd /etc/passwd | ||
COPY --from=common /etc/group /etc/group | ||
COPY --chmod=0755 x86_64-unknown-linux-musl/release/policy-server / | ||
|
||
USER 65533:65533 | ||
# arm64-specific | ||
FROM scratch AS build-arm64 | ||
COPY --from=common /etc/passwd /etc/passwd | ||
COPY --from=common /etc/group /etc/group | ||
COPY --chmod=0755 aarch64-unknown-linux-musl/release/policy-server / | ||
|
||
# common final steps | ||
FROM build-${TARGETARCH} | ||
USER 65533:65533 | ||
EXPOSE 3000 | ||
|
||
ENTRYPOINT ["/usr/local/bin/policy-server"] | ||
ENTRYPOINT ["/policy-server"] |