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 \ + .