Convert Basic-Auth to multi-arch

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
This commit is contained in:
Alistair Hey
2020-11-14 07:20:46 +00:00
committed by Alex Ellis
parent a5583074e0
commit e3b18e6324
12 changed files with 68 additions and 208 deletions

View File

@ -18,10 +18,13 @@ COPY . .
# Run a gofmt and exclude all vendored code.
RUN license-check -path ./ --verbose=false "OpenFaaS Authors" "OpenFaaS Author(s)"
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH } test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH } \
go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \
go test $(go list ./... | grep -v /vendor/) -cover
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test -v ./...
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
--ldflags "-s -w" -a -installsuffix cgo -o handler .
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship
# Add non-root user

View File

@ -1,5 +0,0 @@
TAG?=latest
.PHONY: build
build:
./build.sh ${TAG}

View File

@ -1,30 +0,0 @@
#!/bin/sh
set -e
export arch=$(uname -m)
export eTAG="latest-dev"
export DOCKERFILE="Dockerfile"
if [ "$arch" = "armv7l" ] ; then
eTAG="latest-armhf-dev"
elif [ "$arch" = "aarch64" ] ; then
eTAG="latest-arm64-dev"
DOCKERFILE="Dockerfile.arm64"
fi
echo "$1"
if [ "$1" ] ; then
eTAG=$1
if [ "$arch" = "armv7l" ] ; then
eTAG="$1-armhf"
elif [ "$arch" = "aarch64" ] ; then
eTAG="$1-arm64"
fi
fi
NS=openfaas
echo Building $NS/basic-auth-plugin:$eTAG
docker build -t $NS/basic-auth-plugin:$eTAG . -f $DOCKERFILE

View File

@ -1,27 +0,0 @@
#!/bin/sh
set -e
export arch=$(uname -m)
export eTAG="latest-dev"
if [ "$arch" = "armv7l" ] ; then
eTAG="latest-armhf-dev"
elif [ "$arch" = "aarch64" ] ; then
eTAG="latest-arm64-dev"
fi
echo "$1"
if [ "$1" ] ; then
eTAG=$1
if [ "$arch" = "armv7l" ] ; then
eTAG="$1-armhf"
elif [ "$arch" = "aarch64" ] ; then
eTAG="$1-arm64"
fi
fi
NS=openfaas
echo Pushing $NS/basic-auth-plugin:$eTAG
docker push $NS/basic-auth-plugin:$eTAG