From 11d703efcbd93cf3009319ea1e06f085a8879d81 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 15 Nov 2022 18:14:08 +0100 Subject: [PATCH] Add build scripts and dockerfile --- Dockerfile | 22 ++++++++++++++++++++++ build/docker-multiarch.sh | 9 +++++++++ build/docker-ownarch.sh | 7 +++++++ 3 files changed, 38 insertions(+) create mode 100644 Dockerfile create mode 100644 build/docker-multiarch.sh create mode 100755 build/docker-ownarch.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..83bfc56 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# ---- Base ---- +FROM alpine:3 AS base +WORKDIR /app + + +# ---- 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 + + +# ---- Release ---- +FROM base AS release +# Copy build-target +COPY --from=build /build/app . + +CMD ["./app"] diff --git a/build/docker-multiarch.sh b/build/docker-multiarch.sh new file mode 100644 index 0000000..b63426e --- /dev/null +++ b/build/docker-multiarch.sh @@ -0,0 +1,9 @@ +TAG="ruakij/routingtabletowg" +PLATFORM="linux/amd64,linux/arm64/v8,linux/arm/v7" +EXTRA_ARGS="$@" + +docker buildx build \ +--platform $PLATFORM \ +--tag $TAG \ +$EXTRA_ARGS +. diff --git a/build/docker-ownarch.sh b/build/docker-ownarch.sh new file mode 100755 index 0000000..cee8ba8 --- /dev/null +++ b/build/docker-ownarch.sh @@ -0,0 +1,7 @@ +TAG="ruakij/routingtabletowg" +EXTRA_ARGS="$@" + +docker build \ +--tag $TAG \ +$EXTRA_ARGS \ +.