112 lines
4.3 KiB
YAML
112 lines
4.3 KiB
YAML
language: bash
|
|
|
|
services:
|
|
- docker
|
|
env:
|
|
global:
|
|
- NAME="osixia/openldap"
|
|
- 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;
|
|
# remove pqchecker if arch is not amd64
|
|
- if [[ "${TARGET_ARCH}" != 'amd64' ]]; then
|
|
sed -i -e "/PQCHECKER/Id" image/Dockerfile;
|
|
fi
|
|
- 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}
|
|
# skip test "ldapsearch existing hdb database and config" if arch != amd64
|
|
- if [[ "${TARGET_ARCH}" != 'amd64' ]]; then
|
|
sed -i '/@test "ldapsearch existing hdb database and config"/a skip' test/test.bats;
|
|
fi
|
|
# 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
|