-
Notifications
You must be signed in to change notification settings - Fork 43
/
.travis.yml
103 lines (92 loc) · 3.99 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
language: bash
services:
- docker
env:
global:
- NAME="osixia/openldap-backup"
- VERSION="${TRAVIS_BRANCH}-dev"
matrix:
- TARGET_ARCH=amd64 QEMU_ARCH=x86_64
- TARGET_ARCH=arm32v7 QEMU_ARCH=arm
- TARGET_ARCH=arm64v8 QEMU_ARCH=aarch64
addons:
apt:
# The docker manifest command was added in docker-ee version 18.x
# So update our current installation and we also have to enable the experimental features.
sources:
- sourceline: "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
key_url: "https://download.docker.com/linux/ubuntu/gpg"
packages:
- docker-ce
before_install:
- docker --version
- mkdir $HOME/.docker
- 'echo "{" > $HOME/.docker/config.json'
- 'echo " \"experimental\": \"enabled\"" >> $HOME/.docker/config.json'
- 'echo "}" >> $HOME/.docker/config.json'
- sudo service docker restart
# To have `DOCKER_USER` and `DOCKER_PASS`
# use `travis env set`.
- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
install:
# For cross buidling our images
# This is necessary because travis-ci.org has only x86_64 machines.
# If travis-ci.org gets native arm builds, probably this step is not
# necessary any more.
- docker run --rm --privileged multiarch/qemu-user-static:register --reset
# Bats is necessary for the UT
- curl -o bats.tar.gz -SL https://github.com/bats-core/bats-core/archive/v1.1.0.tar.gz
- mkdir bats-core && tar -xf bats.tar.gz -C bats-core --strip-components=1
- cd bats-core/
- sudo ./install.sh /usr/local
- cd ..
before_script:
# Set baseimage.
- sed -i -e "s/FROM \(.*\)/FROM \1-${TARGET_ARCH}/g" image/Dockerfile;
- cat image/Dockerfile;
# If this is a tag then change the VERSION variable to only have the
# tag name and not also the commit hash.
- if [ -n "$TRAVIS_TAG" ]; then
VERSION=$(echo "${TRAVIS_TAG}" | sed -e 's/\(.*\)[-v]\(.*\)/\1\2/g');
fi
- if [ "${TRAVIS_BRANCH}" == 'master' ]; then
VERSION="stable";
fi
# replace / with - in version
- VERSION=$(echo "${VERSION}" | sed 's|/|-|g');
script:
- make build-nocache NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH}
# Run the test and if the test fails mark the build as failed.
- make test NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH}
before_deploy:
- docker run -d --name test_image ${NAME}:${VERSION}-${TARGET_ARCH} sleep 10
- sleep 5
- sudo docker ps | grep -q test_image
- make tag NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH}
deploy:
provider: script
on:
all_branches: true
script: make push NAME=${NAME} VERSION=${VERSION}-${TARGET_ARCH}
jobs:
include:
- stage: Manifest creation
install: skip
script: skip
after_deploy:
- echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
- docker manifest create ${NAME}:${VERSION} ${NAME}:${VERSION}-amd64 ${NAME}:${VERSION}-arm32v7 ${NAME}:${VERSION}-arm64v8;
docker manifest annotate ${NAME}:${VERSION} ${NAME}:${VERSION}-amd64 --os linux --arch amd64;
docker manifest annotate ${NAME}:${VERSION} ${NAME}:${VERSION}-arm32v7 --os linux --arch arm --variant v7;
docker manifest annotate ${NAME}:${VERSION} ${NAME}:${VERSION}-arm64v8 --os linux --arch arm64 --variant v8;
# The latest tag is coming from the master branch of the repo
- if [ "${TRAVIS_BRANCH}" == 'master' ]; then
docker manifest create ${NAME}:latest ${NAME}:${VERSION}-amd64 ${NAME}:${VERSION}-arm32v7 ${NAME}:${VERSION}-arm64v8;
docker manifest annotate ${NAME}:latest ${NAME}:${VERSION}-amd64 --os linux --arch amd64;
docker manifest annotate ${NAME}:latest ${NAME}:${VERSION}-arm32v7 --os linux --arch arm --variant v7;
docker manifest annotate ${NAME}:latest ${NAME}:${VERSION}-arm64v8 --os linux --arch arm64 --variant v8;
fi
- docker manifest push ${NAME}:${VERSION};
if [ "${TRAVIS_BRANCH}" == 'master' ]; then
docker manifest push ${NAME}:latest;
fi