Skip to content

Commit

Permalink
Re-enable arm builds (#190)
Browse files Browse the repository at this point in the history
* Re-add ARM support

* Introduce arch-dependant distroless images

* Make linker version configurable

* Fix linter issue in docker file

Set "as" keyword upper case, as it should be

* Use equals sign when setting an ENV

S.
https://docs.docker.com/reference/build-checks/legacy-key-value-format/
for details
  • Loading branch information
damyan authored Sep 27, 2024
1 parent b525015 commit 5167002
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions:
packages: write

env:
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
registry: ghcr.io
image: ghcr.io/${{ github.repository_owner }}/fedhcp

Expand Down
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,32 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o fedhcp main.go

FROM debian:stable as installer
FROM debian:stable AS installer

RUN apt-get update \
&& apt-get -y install --no-install-recommends libcap2-bin \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM gcr.io/distroless/static-debian12
FROM gcr.io/distroless/base-debian12 AS distroless-base

FROM distroless-base AS distroless-amd64
ENV LIB_DIR_PREFIX=x86_64
ENV LINKER=ld-linux-x86-64.so.2

FROM distroless-base AS distroless-arm64
ENV LIB_DIR_PREFIX=aarch64
ENV LINKER=ld-linux-aarch64.so.1

FROM distroless-$TARGETARCH AS output-image

WORKDIR /

COPY --from=builder /workspace/fedhcp .
COPY --from=installer /sbin/setcap /sbin/setcap
COPY --from=installer /lib/x86_64-linux-gnu/libcap.so.2 /lib/x86_64-linux-gnu/libcap.so.2
COPY --from=installer /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6
COPY --from=installer /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
COPY --from=installer /lib/${LIB_DIR_PREFIX}-linux-gnu/libcap.so.2 /lib/${LIB_DIR_PREFIX}-linux-gnu/libcap.so.2
COPY --from=installer /lib/${LIB_DIR_PREFIX}-linux-gnu/libc.so.6 /lib/${LIB_DIR_PREFIX}-linux-gnu/libc.so.6
COPY --from=installer /lib/${LIB_DIR_PREFIX}-linux-gnu/${LINKER} /lib/${LIB_DIR_PREFIX}-linux-gnu/${LINKER}
COPY --from=installer /bin/sh /bin/sh

RUN /sbin/setcap 'cap_net_bind_service,cap_net_raw=+ep' /fedhcp
Expand Down

0 comments on commit 5167002

Please sign in to comment.