Skip to content

Commit 8970ce1

Browse files
burtonralexellis
authored andcommitted
Build to create images with binary
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]>
1 parent ca52787 commit 8970ce1

File tree

4 files changed

+60
-9
lines changed

4 files changed

+60
-9
lines changed

.travis.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@ addons:
99
before_install:
1010
script:
1111
- sh build.sh
12+
after_success:
13+
- if [ -z $DOCKER_NS ] ; then
14+
export DOCKER_NS=functions;
15+
fi
16+
- if [ ! -z "$TRAVIS_TAG" ] ; then
17+
export DOCKER_CLI_EXPERIMENTAL=enabled
18+
19+
docker tag $DOCKER_NS/of-watchdog:latest-dev-darwin $DOCKER_NS/of-watchdog:$TRAVIS_TAG-darwin;
20+
docker tag $DOCKER_NS/of-watchdog:latest-dev-armhf $DOCKER_NS/of-watchdog:$TRAVIS_TAG-armhf;
21+
docker tag $DOCKER_NS/of-watchdog:latest-dev-arm64 $DOCKER_NS/of-watchdog:$TRAVIS_TAG-arm64;
22+
docker tag $DOCKER_NS/of-watchdog:latest-dev-windows $DOCKER_NS/of-watchdog:$TRAVIS_TAG-windows;
23+
docker tag $DOCKER_NS/of-watchdog:latest-dev-x86_64 $DOCKER_NS/of-watchdog:$TRAVIS_TAG-x86_64;
24+
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
25+
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-darwin;
26+
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-armhf;
27+
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-arm64;
28+
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-windows;
29+
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG-x86_64;
30+
31+
./make_manifest.sh
32+
docker push $DOCKER_NS/of-watchdog:$TRAVIS_TAG
33+
34+
echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
35+
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-armhf;
36+
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-arm64;
37+
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-windows;
38+
docker push quay.io/$DOCKER_NS/of-watchdog:$TRAVIS_TAG-x86_64;
39+
fi
1240
before_deploy:
1341
- ./ci/hashgen.sh
1442
deploy:
@@ -28,4 +56,4 @@ deploy:
2856
- "./of-watchdog.exe.sha256"
2957
skip_cleanup: true
3058
on:
31-
tags: true
59+
tags: true

Dockerfile.packager

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM functions/of-watchdog:build as build
2+
FROM scratch
3+
4+
ARG PLATFORM
5+
6+
COPY --from=build /go/src/github.com/openfaas-incubator/of-watchdog/of-watchdog$PLATFORM ./fwatchdog

build.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
#!/bin/sh
2-
3-
export arch=$(uname -m)
4-
5-
if [ ! "$arch" = "x86_64" ] ; then
6-
echo "Build not supported on $arch, use cross-build."
7-
exit 1
8-
fi
1+
#!/bin/bash
92

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

10+
docker build --no-cache --build-arg PLATFORM="-darwin" -t openfaas/of-watchdog:latest-dev-darwin . -f Dockerfile.packager
11+
docker build --no-cache --build-arg PLATFORM="-armhf" -t openfaas/of-watchdog:latest-dev-armhf . -f Dockerfile.packager
12+
docker build --no-cache --build-arg PLATFORM="-arm64" -t openfaas/of-watchdog:latest-dev-arm64 . -f Dockerfile.packager
13+
docker build --no-cache --build-arg PLATFORM=".exe" -t openfaas/of-watchdog:latest-dev-windows . -f Dockerfile.packager
14+
docker build --no-cache --build-arg PLATFORM="" -t openfaas/of-watchdog:latest-dev-x86_64 . -f Dockerfile.packager
15+
1716
docker create --name buildoutput functions/of-watchdog:build echo
1817

1918
docker cp buildoutput:/go/src/github.com/openfaas-incubator/of-watchdog/of-watchdog ./of-watchdog

make_manifest.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
export USR=$DOCKER_NS
4+
export TAG=$TRAVIS_TAG
5+
6+
docker manifest create $USR/of-watchdog:$TAG \
7+
$USR/of-watchdog:$TAG-darwin \
8+
$USR/of-watchdog:$TAG-x86_64 \
9+
$USR/of-watchdog:$TAG-armhf \
10+
$USR/of-watchdog:$TAG-arm64 \
11+
$USR/of-watchdog:$TAG-windows
12+
13+
docker manifest annotate $USR/of-watchdog:$TAG --arch arm $USR/of-watchdog:$TAG-darwin
14+
docker manifest annotate $USR/of-watchdog:$TAG --arch arm $USR/of-watchdog:$TAG-armhf
15+
docker manifest annotate $USR/of-watchdog:$TAG --arch arm64 $USR/of-watchdog:$TAG-arm64
16+
docker manifest annotate $USR/of-watchdog:$TAG --os windows $USR/of-watchdog:$TAG-windows
17+
18+
docker manifest push $USR/of-watchdog:$TAG

0 commit comments

Comments
 (0)