forked from oznu/docker-cloudflare-ddns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
55 lines (47 loc) · 3.01 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
language: bash
services:
- docker
env:
- S6_ARCH=amd64 DOCKERFILE="Dockerfile" TAG_SUFFIX="amd64"
- S6_ARCH=armhf DOCKERFILE="Dockerfile" TAG_SUFFIX="arm32v6" ALT_SUFFIX="armhf"
- S6_ARCH=aarch64 DOCKERFILE="Dockerfile" TAG_SUFFIX="arm64v8" ALT_SUFFIX="aarch64"
script:
- sudo apt-get --yes --no-install-recommends install binfmt-support qemu-user-static
- docker run --rm --privileged multiarch/qemu-user-static:register --reset
- export TARGET_IMAGE_TAG=$(if [ "$TRAVIS_BRANCH" = "master" ]; then if [ "$TAG_SUFFIX" = "" ]; then echo "latest"; else echo "$TAG_SUFFIX"; fi; else if [ "$TAG_SUFFIX" = "" ]; then echo "$TRAVIS_BRANCH"; else echo "$TRAVIS_BRANCH-$TAG_SUFFIX"; fi; fi)
- docker pull $TARGET_IMAGE:$TARGET_IMAGE_TAG && export IMAGE_CACHE="--cache-from $TARGET_IMAGE:$TARGET_IMAGE_TAG" || export IMAGE_CACHE=""
- docker build -f $DOCKERFILE $IMAGE_CACHE --build-arg S6_ARCH=${S6_ARCH} -t $TARGET_IMAGE:$TARGET_IMAGE_TAG .
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
- docker push $TARGET_IMAGE:$TARGET_IMAGE_TAG
# push alternate tags
- if [ -z "$ALT_SUFFIX" ]; then
echo "No alternate tags set for this build.";
else
echo "Tagging with alternate tag '$ALT_SUFFIX'";
export ALT_IMAGE_TAG=$(if [ "$TRAVIS_BRANCH" = "master" ]; then if [ "$ALT_SUFFIX" = "" ]; then echo "error"; else echo "$ALT_SUFFIX"; fi; else if [ "$ALT_SUFFIX" = "" ]; then echo "$TRAVIS_BRANCH"; else echo "$TRAVIS_BRANCH-$ALT_SUFFIX"; fi; fi);
docker tag $TARGET_IMAGE:$TARGET_IMAGE_TAG $TARGET_IMAGE:$ALT_IMAGE_TAG;
docker push $TARGET_IMAGE:$ALT_IMAGE_TAG;
fi
jobs:
include:
- stage: manifest
script:
# update docker to edge
- sudo apt update -y
- sudo apt install --only-upgrade docker-ce -y
# enable experimental to use docker manifest command
- mkdir $HOME/.docker
- |-
echo '{"experimental": "enabled"}' | tee $HOME/.docker/config.json
- |-
echo '{"experimental": true,"storage-driver": "overlay2","max-concurrent-downloads": 50,"max-concurrent-uploads": 50}' | sudo tee /etc/docker/daemon.json
- sudo service docker restart
# login
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# main
- export MANIFEST_SUFFIX=$(if [ "$TRAVIS_BRANCH" = "master" ]; then echo "latest"; else echo "$TRAVIS_BRANCH"; fi)
- export TAG_PREFIX=$(if [ "$TRAVIS_BRANCH" = "master" ]; then echo ""; else echo "$TRAVIS_BRANCH-"; fi)
- docker manifest create $TARGET_IMAGE:$MANIFEST_SUFFIX $TARGET_IMAGE:${TAG_PREFIX}amd64 $TARGET_IMAGE:${TAG_PREFIX}arm32v6 $TARGET_IMAGE:${TAG_PREFIX}arm64v8
- docker manifest annotate $TARGET_IMAGE:$MANIFEST_SUFFIX $TARGET_IMAGE:${TAG_PREFIX}arm32v6 --os=linux --arch=arm --variant=v6
- docker manifest annotate $TARGET_IMAGE:$MANIFEST_SUFFIX $TARGET_IMAGE:${TAG_PREFIX}arm64v8 --os=linux --arch=arm64 --variant=v8
- docker manifest push $TARGET_IMAGE:$MANIFEST_SUFFIX