mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 16:56:47 +00:00
Convert Basic-Auth to multi-arch
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
This commit is contained in:
parent
a5583074e0
commit
e3b18e6324
74
.github/workflows/build.yml
vendored
74
.github/workflows/build.yml
vendored
@ -7,10 +7,9 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- '*'
|
- '*'
|
||||||
# Auth
|
|
||||||
# Watchdog containers
|
|
||||||
# Watchdog bins + shas
|
|
||||||
|
|
||||||
|
# pull buildargs out of container (stop putting git in)
|
||||||
|
# can then go back to matrix build of containers
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
# Run the CI tests
|
# Run the CI tests
|
||||||
@ -28,8 +27,32 @@ jobs:
|
|||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Get TAG
|
||||||
|
id: get_tag
|
||||||
|
run: echo ::set-output name=TAG::latest-dev
|
||||||
|
- name: Get Repo Owner
|
||||||
|
id: get_repo_owner
|
||||||
|
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
||||||
|
- name: Build Gateway
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./gateway
|
||||||
|
file: ./gateway/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
load: true
|
||||||
|
push: false
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ steps.get_tag.outputs.TAG }}
|
||||||
|
GIT_COMMIT=${{ github.sha }}
|
||||||
|
GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }}
|
||||||
|
tags: |
|
||||||
|
ghcr.io/openfaas/gateway:latest-dev
|
||||||
- name: Run CI
|
- name: Run CI
|
||||||
run: make build test-ci
|
run: make test-ci
|
||||||
|
|
||||||
build-gateway:
|
build-gateway:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -49,45 +72,18 @@ jobs:
|
|||||||
run: echo ::set-output name=TAG::latest-dev
|
run: echo ::set-output name=TAG::latest-dev
|
||||||
- name: Get Repo Owner
|
- name: Get Repo Owner
|
||||||
id: get_repo_owner
|
id: get_repo_owner
|
||||||
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
|
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
||||||
- name: Build Gateway
|
- name: Build ${{ matrix.svc }}
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: ./gateway
|
||||||
file: ./gateway/Dockerfile
|
|
||||||
outputs: "type=image,push=false"
|
|
||||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
|
||||||
tags: |
|
|
||||||
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
|
|
||||||
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
|
|
||||||
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:latest
|
|
||||||
|
|
||||||
build-watchdog:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go-version: [1.13.x]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@master
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- name: Get TAG
|
|
||||||
id: get_tag
|
|
||||||
run: echo ::set-output name=TAG::latest-dev
|
|
||||||
- name: Get Repo Owner
|
|
||||||
id: get_repo_owner
|
|
||||||
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
|
|
||||||
- name: Build Watchdog
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./gateway/Dockerfile
|
file: ./gateway/Dockerfile
|
||||||
outputs: "type=image,push=false"
|
outputs: "type=image,push=false"
|
||||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ steps.get_tag.outputs.TAG }}
|
||||||
|
GIT_COMMIT=${{ github.sha }}
|
||||||
|
GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }}
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
|
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ steps.get_tag.outputs.TAG }}
|
||||||
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
|
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/gateway:${{ github.sha }}
|
||||||
@ -113,7 +109,7 @@ jobs:
|
|||||||
run: echo ::set-output name=TAG::latest-dev
|
run: echo ::set-output name=TAG::latest-dev
|
||||||
- name: Get Repo Owner
|
- name: Get Repo Owner
|
||||||
id: get_repo_owner
|
id: get_repo_owner
|
||||||
run: echo ::set-output name=repo_owner::$(echo ${{ github.event.repository.owner.login }} | tr '[:upper:]' '[:lower:]')
|
run: echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
||||||
- name: Build ${{ matrix.svc }}
|
- name: Build ${{ matrix.svc }}
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
|
8
Makefile
8
Makefile
@ -1,10 +1,6 @@
|
|||||||
TAG?=latest
|
TAG?=latest
|
||||||
NS?=openfaas
|
NS?=openfaas
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build:
|
|
||||||
./build.sh
|
|
||||||
|
|
||||||
.PHONY: build-gateway
|
.PHONY: build-gateway
|
||||||
build-gateway:
|
build-gateway:
|
||||||
(cd gateway; docker buildx build --platform linux/amd64 -t $NS/gateway:latest-dev .)
|
(cd gateway; docker buildx build --platform linux/amd64 -t $NS/gateway:latest-dev .)
|
||||||
@ -12,7 +8,3 @@ build-gateway:
|
|||||||
.PHONY: test-ci
|
.PHONY: test-ci
|
||||||
test-ci:
|
test-ci:
|
||||||
./contrib/ci.sh
|
./contrib/ci.sh
|
||||||
|
|
||||||
.PHONY: binaries
|
|
||||||
binaries:
|
|
||||||
echo TODO
|
|
@ -18,10 +18,13 @@ COPY . .
|
|||||||
# Run a gofmt and exclude all vendored code.
|
# Run a gofmt and exclude all vendored code.
|
||||||
|
|
||||||
RUN license-check -path ./ --verbose=false "OpenFaaS Authors" "OpenFaaS Author(s)"
|
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 } \
|
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
|
||||||
go build --ldflags "-s -w" -a -installsuffix cgo -o handler . && \
|
|
||||||
go test $(go list ./... | grep -v /vendor/) -cover
|
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
|
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.12 as ship
|
||||||
# Add non-root user
|
# Add non-root user
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
TAG?=latest
|
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build:
|
|
||||||
./build.sh ${TAG}
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
9
build.sh
9
build.sh
@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ ! -s "$TAG" ] ; then
|
|
||||||
echo "This build will be published under the tag: ${TAG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
(cd gateway && ./build.sh)
|
|
||||||
(cd auth/basic-auth && ./build.sh)
|
|
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
IMAGE_REGISTRY=$1
|
|
||||||
IMAGE_NAME=$2
|
|
||||||
PLATFORM=""
|
|
||||||
|
|
||||||
if [ ! -z "$3" ]; then
|
|
||||||
PLATFORM="-$3"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Tagging $IMAGE_REGISTRY/$IMAGE_NAME:$TRAVIS_TAG$PLATFORM"
|
|
||||||
docker tag $IMAGE_NAME:latest-dev$PLATFORM $IMAGE_REGISTRY/$IMAGE_NAME:$TRAVIS_TAG$PLATFORM;
|
|
||||||
|
|
||||||
echo "Pushing $IMAGE_REGISTRY/$IMAGE_NAME:$TRAVIS_TAG$PLATFORM"
|
|
||||||
docker push $IMAGE_REGISTRY/$IMAGE_NAME:$TRAVIS_TAG$PLATFORM;
|
|
@ -6,7 +6,7 @@ set -e
|
|||||||
|
|
||||||
# The timeout is required on Travis due to some tasks not starting in
|
# The timeout is required on Travis due to some tasks not starting in
|
||||||
# time and being deemed to have failed.
|
# time and being deemed to have failed.
|
||||||
docker service update func_gateway --image=openfaas/gateway:latest-dev \
|
docker service update func_gateway --image=ghcr.io/openfaas/gateway:latest-dev \
|
||||||
--update-failure-action=continue \
|
--update-failure-action=continue \
|
||||||
--update-monitor=20s
|
--update-monitor=20s
|
||||||
|
|
||||||
@ -32,11 +32,13 @@ fi
|
|||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
echo $GOPATH
|
if [ -z "$GOPATH" ]
|
||||||
|
then
|
||||||
|
export GOPATH=$GITHUB_WORKSPACE
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d "$GOPATH/src/github.com/openfaas/" ]; then
|
if [ ! -d "$GOPATH/src/github.com/openfaas/" ]; then
|
||||||
mkdir -p $GOPATH/src/github.com/openfaas/
|
mkdir -p $GOPATH/src/github.com/openfaas/
|
||||||
cp -r faas $GOPATH/src/github.com/openfaas/
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$GOPATH/src/github.com/openfaas/certifier" ]; then
|
if [ ! -d "$GOPATH/src/github.com/openfaas/certifier" ]; then
|
||||||
|
@ -10,42 +10,39 @@ ARG BUILDPLATFORM
|
|||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
ARG GIT_COMMIT_SHA
|
ARG GIT_COMMIT
|
||||||
ARG GIT_COMMIT_MESSAGE
|
ARG GIT_COMMIT_MESSAGE
|
||||||
ARG VERSION='dev'
|
ARG VERSION
|
||||||
|
|
||||||
COPY --from=license-check /license-check /usr/bin/
|
COPY --from=license-check /license-check /usr/bin/
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/openfaas/faas/gateway
|
WORKDIR /go/src/github.com/openfaas/faas/gateway
|
||||||
|
|
||||||
COPY gateway/vendor vendor
|
COPY vendor vendor
|
||||||
|
|
||||||
COPY gateway/handlers handlers
|
COPY handlers handlers
|
||||||
COPY gateway/metrics metrics
|
COPY metrics metrics
|
||||||
COPY gateway/requests requests
|
COPY requests requests
|
||||||
COPY gateway/tests tests
|
COPY tests tests
|
||||||
|
|
||||||
COPY gateway/types types
|
COPY types types
|
||||||
COPY gateway/queue queue
|
COPY queue queue
|
||||||
COPY gateway/plugin plugin
|
COPY plugin plugin
|
||||||
COPY gateway/version version
|
COPY version version
|
||||||
COPY gateway/scaling scaling
|
COPY scaling scaling
|
||||||
COPY gateway/pkg pkg
|
COPY pkg pkg
|
||||||
COPY gateway/main.go .
|
COPY main.go .
|
||||||
COPY .git .
|
|
||||||
RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Authors" "OpenFaaS Author(s)"
|
RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Authors" "OpenFaaS Author(s)"
|
||||||
|
|
||||||
|
|
||||||
# Run a gofmt and exclude all vendored code.
|
# Run a gofmt and exclude all vendored code.
|
||||||
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
|
RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))"
|
||||||
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover
|
RUN go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover
|
||||||
RUN GIT_COMMIT_MESSAGE=$(git log -1 --pretty=%B 2>&1 | head -n 1) \
|
|
||||||
GIT_COMMIT_SHA=$(git rev-list -1 HEAD) \
|
RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w \
|
||||||
VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///' || echo dev) \
|
-X \"github.com/openfaas/faas/gateway/version.GitCommitSHA=${GIT_COMMIT}\" \
|
||||||
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w \
|
-X \"github.com/openfaas/faas/gateway/version.GitCommitMessage=${GIT_COMMIT_MESSAGE}\" \
|
||||||
-X github.com/openfaas/faas/gateway/version.GitCommitSHA=${GIT_COMMIT_SHA} \
|
-X \"github.com/openfaas/faas/gateway/version.Version=${VERSION}\" \
|
||||||
-X github.com/openfaas/faas/gateway/version.GitCommitMessage=${GIT_COMMIT_MESSAGE} \
|
|
||||||
-X github.com/openfaas/faas/gateway/version.Version=${VERSION} \
|
|
||||||
-X github.com/openfaas/faas/gateway/types.Arch=${TARGETARCH}" \
|
-X github.com/openfaas/faas/gateway/types.Arch=${TARGETARCH}" \
|
||||||
-a -installsuffix cgo -o gateway .
|
-a -installsuffix cgo -o gateway .
|
||||||
|
|
||||||
@ -70,7 +67,7 @@ ENV http_proxy ""
|
|||||||
ENV https_proxy ""
|
ENV https_proxy ""
|
||||||
|
|
||||||
COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway .
|
COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway .
|
||||||
COPY gateway/assets assets
|
COPY assets assets
|
||||||
RUN sed -ie s/x86_64/${GOARCH}/g assets/script/funcstore.js && \
|
RUN sed -ie s/x86_64/${GOARCH}/g assets/script/funcstore.js && \
|
||||||
rm assets/script/funcstore.jse
|
rm assets/script/funcstore.jse
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
.PHONY: all build push
|
|
||||||
TAG?=latest
|
|
||||||
NS?=openfaas
|
|
||||||
|
|
||||||
all: build
|
|
||||||
build:
|
|
||||||
./build.sh ${TAG} ${NS}
|
|
||||||
push:
|
|
||||||
./push.sh ${TAG} ${NS}
|
|
@ -1,34 +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
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$2" ] ; then
|
|
||||||
NS=$2
|
|
||||||
else
|
|
||||||
NS=openfaas
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo Pushing $NS/gateway:$eTAG
|
|
||||||
|
|
||||||
docker push $NS/gateway:$eTAG
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user