From 34bfe19158c22633d273d9e4399436c4dd94a4e3 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 11 Apr 2023 11:36:49 +0200 Subject: [PATCH] Add build-scripts with docker --- build/Dockerfile | 13 +++++++++++++ build/build-multiarch.sh | 9 +++++++++ build/build-ownarch.sh | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 build/Dockerfile create mode 100755 build/build-multiarch.sh create mode 100755 build/build-ownarch.sh diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..1b1762c --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,13 @@ +# ---- Build ---- +FROM golang:1.19-alpine AS build +WORKDIR /build +# Copy sources +ADD . . +# Get dependencies +RUN go get ./cmd/app +# Compile +RUN CGO_ENABLED=0 go build -a -o app ./cmd/app + +# ---- Output ---- +FROM scratch AS export-stage +COPY --from=build /build/app . diff --git a/build/build-multiarch.sh b/build/build-multiarch.sh new file mode 100755 index 0000000..2cf8691 --- /dev/null +++ b/build/build-multiarch.sh @@ -0,0 +1,9 @@ +PLATFORM="linux/amd64,linux/arm64/v8,linux/arm/v7" +EXTRA_ARGS="$@" + +docker buildx build \ + --platform $PLATFORM \ + -f $(dirname $0)/Dockerfile \ + --output out \ + $EXTRA_ARGS \ + . diff --git a/build/build-ownarch.sh b/build/build-ownarch.sh new file mode 100755 index 0000000..dff75fc --- /dev/null +++ b/build/build-ownarch.sh @@ -0,0 +1,7 @@ +EXTRA_ARGS="$@" + +docker build \ + -f $(dirname $0)/Dockerfile \ + --output out \ + $EXTRA_ARGS \ + .