From ba4e0a93ed05ba84541f2e3fe2c233953cbf785a Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Tue, 29 Mar 2022 10:14:59 +0100 Subject: [PATCH] Multi-arch Docker image buildkit --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker-entrypoint.sh | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e3539b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM alpine:3.14 as intermediate + +RUN mkdir /src +WORKDIR /src + +# Install the build tools +RUN apk add git go make + +# Fetch the source +RUN git clone https://github.com/slackhq/nebula.git + +# Compile the Linux binaries for all platforms +WORKDIR /src/nebula +RUN echo 'bin-linux: $(ALL_LINUX:%=build/%/nebula) $(ALL_LINUX:%=build/%/nebula-cert)' >> Makefile +RUN make bin-linux + +# Start from a clean image +FROM alpine:3.14 + +RUN mkdir /app +WORKDIR /app + +# Copy over the compiled binaries +COPY --from=intermediate /src/nebula/build ./ + +# Rename the directories from `go env` format to `uname` format +RUN mv linux-amd64 linux-x86_64 + +COPY docker-entrypoint.sh entrypoint.sh +ENTRYPOINT [ "/bin/sh", "/app/entrypoint.sh" ] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..8a61f1a --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Run the platform-specific binary +"/app/linux-$(uname -m)/nebula"