Multi-arch Docker image buildkit

This commit is contained in:
Scott Wallace 2022-03-29 10:14:59 +01:00
parent fcfdc28809
commit ba4e0a93ed
Signed by: scott
GPG key ID: AA742FDC5AFE2A72
2 changed files with 34 additions and 0 deletions

30
Dockerfile Normal file
View file

@ -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" ]

4
docker-entrypoint.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/sh
# Run the platform-specific binary
"/app/linux-$(uname -m)/nebula"