Skip to content

Commit

Permalink
Build to create images with binary
Browse files Browse the repository at this point in the history
Update the build to create images of the binaries for each
of the supported platforms: darwin, armhf, arm64, windows,
and x86_64 (linux)

Also updated the travis file in order to push these images
up to docker hub and create a manifest file for easy
multi-arch image pulls

Signed-off-by: Burton Rheutan <[email protected]>
  • Loading branch information
burtonr authored and alexellis committed Jun 4, 2019
1 parent ca52787 commit 8970ce1
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
30 changes: 29 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ addons:
before_install:
script:
- sh build.sh
after_success:
- if [ -z $DOCKER_NS ] ; then
export DOCKER_NS=functions;
fi
- if [ ! -z "$TRAVIS_TAG" ] ; then
export DOCKER_CLI_EXPERIMENTAL=enabled

docker tag $DOCKER_NS/of-watchdog:latest-dev-darwin $DOCKER_NS/of-watchdog:$TRAVIS_TAG-darwin;
docker tag $DOCKER_NS/of-watchdog:latest-dev-armhf $DOCKER_NS/of-watchdog:$TRAVIS_TAG-armhf;
docker tag $DOCKER_NS/of-watchdog:latest-dev-arm64 $DOCKER_NS/of-watchdog:$TRAVIS_TAG-arm64;
docker tag $DOCKER_NS/of-watchdog:latest-dev-windows $DOCKER_NS/of-watchdog:$TRAVIS_TAG-windows;
docker tag $DOCKER_NS/of-watchdog:latest-dev-x86_64 $DOCKER_NS/of-watchdog:$TRAVIS_TAG-x86_64;
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-darwin;
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-armhf;
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-arm64;
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-windows;
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-x86_64;

./make_manifest.sh
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG

echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-armhf;
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-arm64;
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-windows;
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-x86_64;
fi
before_deploy:
- ./ci/hashgen.sh
deploy:
Expand All @@ -28,4 +56,4 @@ deploy:
- "./of-watchdog.exe.sha256"
skip_cleanup: true
on:
tags: true
tags: true
6 changes: 6 additions & 0 deletions Dockerfile.packager
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM functions/of-watchdog:build as build
FROM scratch

ARG PLATFORM

COPY --from=build /go/src/github.com/openfaas-incubator/of-watchdog/of-watchdog$PLATFORM ./fwatchdog
15 changes: 7 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
#!/bin/sh

export arch=$(uname -m)

if [ ! "$arch" = "x86_64" ] ; then
echo "Build not supported on $arch, use cross-build."
exit 1
fi
#!/bin/bash

if [ ! "$http_proxy" = "" ]
then
Expand All @@ -14,6 +7,12 @@ else
docker build -t functions/of-watchdog:build .
fi

docker build --no-cache --build-arg PLATFORM="-darwin" -t openfaas/of-watchdog:latest-dev-darwin . -f Dockerfile.packager
docker build --no-cache --build-arg PLATFORM="-armhf" -t openfaas/of-watchdog:latest-dev-armhf . -f Dockerfile.packager
docker build --no-cache --build-arg PLATFORM="-arm64" -t openfaas/of-watchdog:latest-dev-arm64 . -f Dockerfile.packager
docker build --no-cache --build-arg PLATFORM=".exe" -t openfaas/of-watchdog:latest-dev-windows . -f Dockerfile.packager
docker build --no-cache --build-arg PLATFORM="" -t openfaas/of-watchdog:latest-dev-x86_64 . -f Dockerfile.packager

docker create --name buildoutput functions/of-watchdog:build echo

docker cp buildoutput:/go/src/github.com/openfaas-incubator/of-watchdog/of-watchdog ./of-watchdog
Expand Down
18 changes: 18 additions & 0 deletions make_manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

export USR=$DOCKER_NS
export TAG=$TRAVIS_TAG

docker manifest create $USR/of-watchdog:$TAG \
$USR/of-watchdog:$TAG-darwin \
$USR/of-watchdog:$TAG-x86_64 \
$USR/of-watchdog:$TAG-armhf \
$USR/of-watchdog:$TAG-arm64 \
$USR/of-watchdog:$TAG-windows

docker manifest annotate $USR/of-watchdog:$TAG --arch arm $USR/of-watchdog:$TAG-darwin
docker manifest annotate $USR/of-watchdog:$TAG --arch arm $USR/of-watchdog:$TAG-armhf
docker manifest annotate $USR/of-watchdog:$TAG --arch arm64 $USR/of-watchdog:$TAG-arm64
docker manifest annotate $USR/of-watchdog:$TAG --os windows $USR/of-watchdog:$TAG-windows

docker manifest push $USR/of-watchdog:$TAG

0 comments on commit 8970ce1

Please sign in to comment.