language: bash services: - docker env: global: - NAME="osixia/light-baseimage" - VERSION="${TRAVIS_BRANCH}-dev" matrix: - TARGET_ARCH=amd64 QEMU_ARCH=x86_64 - TARGET_ARCH=i386 QEMU_ARCH=i386 - 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: # Injecting the necessary information and binaries for cross-compiling the images. # In native builds this information and binaries are not necessary and that is why # we are injecting them in the build scripts and we do not include them in the Dockerfiles - if [[ "${TARGET_ARCH}" != 'amd64' ]]; then sed -i "s/FROM alpine/FROM ${TARGET_ARCH}\/alpine/" image/Dockerfile; fi - if [[ "${TARGET_ARCH}" != 'amd64' ]]; then sed -i "/${TARGET_ARCH}\/alpine/a COPY \ --from=multiarch/qemu-user-static:x86_64-${QEMU_ARCH} \ /usr/bin/qemu-${QEMU_ARCH}-static /usr/bin/" 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} # 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}-i386 ${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}-i386 --os linux --arch 386; 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 stable branch of the repo - if [ "${TRAVIS_BRANCH}" == 'master' ]; then docker manifest create ${NAME}:latest ${NAME}:${VERSION}-amd64 ${NAME}:${VERSION}-i386 ${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}-i386 --os linux --arch 386; 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