mirror of
https://github.com/openfaas/faas.git
synced 2025-06-26 16:53:26 +00:00
Refactor CI and enable auto-builds for auth
Automatic builds for auth-module on x86_64 (via Travis) and on-demand on-device for arm via publish.sh The basic-auth module is not built or pushed upon 'tag' / 'release' of the faas repo, but it should be: https://github.com/openfaas/faas/tree/master/auth. We also don't create on-device images for this, but should do for both armhf and arm64: https://github.com/openfaas/faas/blob/master/contrib/publish-arm.sh This change addresses these challenges and also introduces a tagAndPush script to alleviate some of the recently introduced repetition in .travis.yml. Signed-off-by: Richard Gee <richard@technologee.co.uk>
This commit is contained in:
31
.travis.yml
31
.travis.yml
@ -26,38 +26,19 @@ after_success:
|
||||
- if [ ! -z "$TRAVIS_TAG" ] ; then
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
|
||||
docker tag $DOCKER_NS/gateway:latest-dev $DOCKER_NS/gateway:$TRAVIS_TAG;
|
||||
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
|
||||
docker push $DOCKER_NS/gateway:$TRAVIS_TAG;
|
||||
|
||||
docker tag $DOCKER_NS/gateway:latest-dev quay.io/$DOCKER_NS/gateway:$TRAVIS_TAG;
|
||||
echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
|
||||
docker push quay.io/$DOCKER_NS/gateway:$TRAVIS_TAG;
|
||||
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-armhf $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-armhf;
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-arm64 $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-arm64;
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-windows $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-windows;
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-x86_64 $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-x86_64;
|
||||
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
|
||||
docker push $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-armhf;
|
||||
docker push $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-arm64;
|
||||
docker push $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-windows;
|
||||
docker push $DOCKER_NS/classic-watchdog:$TRAVIS_TAG-x86_64;
|
||||
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-armhf quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-armhf;
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-arm64 quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-arm64;
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-windows quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-windows;
|
||||
docker tag $DOCKER_NS/classic-watchdog:latest-dev-x86_64 quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-x86_64;
|
||||
./ci/tagAndPush.sh "$DOCKER_NS/gateway";
|
||||
./ci/tagAndPush.sh "$DOCKER_NS/basic-auth-plugin";
|
||||
./ci/tagAndPush.sh "$DOCKER_NS/classic-watchdog" armhf;
|
||||
./ci/tagAndPush.sh "$DOCKER_NS/classic-watchdog" arm64;
|
||||
./ci/tagAndPush.sh "$DOCKER_NS/classic-watchdog" windows;
|
||||
./ci/tagAndPush.sh "$DOCKER_NS/classic-watchdog" x86_64;
|
||||
|
||||
./watchdog/make_manifest.sh
|
||||
docker push $DOCKER_NS/classic-watchdog:$TRAVIS_TAG
|
||||
|
||||
echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
|
||||
docker push quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-armhf;
|
||||
docker push quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-arm64;
|
||||
docker push quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-windows;
|
||||
docker push quay.io/$DOCKER_NS/classic-watchdog:$TRAVIS_TAG-x86_64;
|
||||
|
||||
fi
|
||||
|
||||
before_deploy:
|
||||
|
8
Makefile
8
Makefile
@ -14,16 +14,16 @@ test-ci:
|
||||
|
||||
.PHONY: ci-armhf-build
|
||||
ci-armhf-build:
|
||||
(cd gateway; ./build.sh $(TAG))
|
||||
(cd gateway; ./build.sh $(TAG) ; cd ../auth/basic-auth ; ./build.sh $(TAG))
|
||||
|
||||
.PHONY: ci-armhf-push
|
||||
ci-armhf-push:
|
||||
(cd gateway; ./push.sh $(TAG))
|
||||
(cd gateway; ./push.sh $(TAG) ; cd ../auth/basic-auth ; ./push.sh $(TAG))
|
||||
|
||||
.PHONY: ci-arm64-build
|
||||
ci-arm64-build:
|
||||
(cd gateway; ./build.sh $(TAG))
|
||||
(cd gateway; ./build.sh $(TAG) ; cd ../auth/basic-auth ; ./build.sh $(TAG))
|
||||
|
||||
.PHONY: ci-arm64-push
|
||||
ci-arm64-push:
|
||||
(cd gateway; ./push.sh $(TAG))
|
||||
(cd gateway; ./push.sh $(TAG) ; cd ../auth/basic-auth ; ./push.sh $(TAG))
|
||||
|
@ -2,4 +2,4 @@ TAG?=latest
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
docker build -t openfaas/basic-auth-plugin:${TAG} .
|
||||
./build.sh ${TAG}
|
||||
|
27
auth/basic-auth/build.sh
Executable file
27
auth/basic-auth/build.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/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 Building $NS/basic-auth-plugin:$eTAG
|
||||
|
||||
docker build -t $NS/basic-auth-plugin:$eTAG .
|
27
auth/basic-auth/push.sh
Executable file
27
auth/basic-auth/push.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/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
|
1
build.sh
1
build.sh
@ -7,3 +7,4 @@ fi
|
||||
|
||||
(cd gateway && ./build.sh)
|
||||
(cd watchdog && ./build.sh)
|
||||
(cd auth/basic-auth && ./build.sh)
|
17
ci/tagAndPush.sh
Executable file
17
ci/tagAndPush.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
IMAGE_NAME=$1
|
||||
PLATFORM=""
|
||||
|
||||
if [ ! -z "$2" ]; then
|
||||
PLATFORM="-$2"
|
||||
fi
|
||||
|
||||
echo "Tagging $IMAGE_NAME:$TRAVIS_TAG$PLATFORM"
|
||||
docker tag $IMAGE_NAME:latest-dev$PLATFORM $IMAGE_NAME:$TRAVIS_TAG$PLATFORM;
|
||||
docker tag $IMAGE_NAME:latest-dev$PLATFORM quay.io/$IMAGE_NAME:$TRAVIS_TAG$PLATFORM;
|
||||
|
||||
echo "Pushing $IMAGE_NAME:$TRAVIS_TAG$PLATFORM"
|
||||
docker push $IMAGE_NAME:$TRAVIS_TAG$PLATFORM;
|
||||
docker push quay.io/$IMAGE_NAME:$TRAVIS_TAG$PLATFORM;
|
@ -11,17 +11,17 @@ ARCH=$(uname -m)
|
||||
|
||||
#fi
|
||||
|
||||
get_repo_name() {
|
||||
get_image_names() {
|
||||
if [ "openfaas-incubator/faas-idler" = $1 ]; then
|
||||
echo "openfaas/faas-idler"
|
||||
images=("openfaas/faas-idler")
|
||||
elif [ "openfaas/faas" = $1 ]; then
|
||||
echo "openfaas/gateway"
|
||||
images=("openfaas/gateway" "openfaas/basic-auth-plugin")
|
||||
elif [ "openfaas/nats-queue-worker" = $1 ]; then
|
||||
echo "openfaas/queue-worker"
|
||||
images=("openfaas/queue-worker")
|
||||
elif [ "openfaas-incubator/openfaas-operator" = $1 ]; then
|
||||
echo "openfaas/openfaas-operator"
|
||||
images=("openfaas/openfaas-operator")
|
||||
else
|
||||
echo $1
|
||||
images=($1)
|
||||
fi
|
||||
}
|
||||
|
||||
@ -33,35 +33,48 @@ fi
|
||||
|
||||
echo "Target architecture: ${ARM_VERSION}"
|
||||
|
||||
for i in "${repos[@]}"
|
||||
for r in "${repos[@]}"
|
||||
do
|
||||
cd $HERE
|
||||
|
||||
echo -e "\nBuilding: $i\n"
|
||||
git clone https://github.com/$i ./staging/$i
|
||||
cd ./staging/$i
|
||||
echo -e "\nBuilding: $r\n"
|
||||
git clone https://github.com/$r ./staging/$r
|
||||
cd ./staging/$r
|
||||
pwd
|
||||
export TAG=$(git describe --abbrev=0 --tags)
|
||||
echo "Latest release: $TAG"
|
||||
|
||||
REPOSITORY=$(get_repo_name $i)
|
||||
TAG_PRESENT=$(curl -s "https://hub.docker.com/v2/repositories/${REPOSITORY}/tags/${TAG}-${ARM_VERSION}/" | grep -Po '"detail": *"[^"]*"' | grep -o 'Not found')
|
||||
get_image_names $r
|
||||
|
||||
for IMAGE in "${images[@]}"
|
||||
do
|
||||
TAG_PRESENT=$(curl -s "https://hub.docker.com/v2/repositories/${IMAGE}/tags/${TAG}-${ARM_VERSION}/" | grep -Po '"detail": *"[^"]*"' | grep -o 'Not found')
|
||||
if [ "$TAG_PRESENT" = "Not found" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$TAG_PRESENT" = "Not found" ]; then
|
||||
make ci-${ARM_VERSION}-build ci-${ARM_VERSION}-push
|
||||
else
|
||||
echo "Image is already present: ${REPOSITORY}:${TAG}-${ARM_VERSION}"
|
||||
for IMAGE in "${images[@]}"
|
||||
do
|
||||
echo "Image is already present: ${IMAGE}:${TAG}-${ARM_VERSION}"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Docker images"
|
||||
|
||||
for i in "${repos[@]}"
|
||||
for r in "${repos[@]}"
|
||||
do
|
||||
cd $HERE
|
||||
cd ./staging/$i
|
||||
cd ./staging/$r
|
||||
export TAG=$(git describe --abbrev=0 --tags)
|
||||
echo "$i"
|
||||
REPOSITORY=$(get_repo_name $i)
|
||||
echo " ${REPOSITORY}:${TAG}-${ARM_VERSION}"
|
||||
echo "$r"
|
||||
get_image_names $r
|
||||
for IMAGE in "${images[@]}"
|
||||
do
|
||||
echo " ${IMAGE}:${TAG}-${ARM_VERSION}"
|
||||
done
|
||||
done
|
Reference in New Issue
Block a user