forked from YinAoXiong/12306_code_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
44 lines (40 loc) · 1.72 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
dist: bionic
sudo: required
services:
- docker
language: bash
env:
- IMAGE_NAME=12306_code_server DOCKER_CLI_EXPERIMENTAL=enabled
addons:
apt:
packages:
- docker-ce
install:
- docker --version
- docker run --rm --privileged multiarch/qemu-user-static:register --reset
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- chmod +x qemu/qemu-aarch64-static && chmod +x qemu/qemu-arm-static
script:
- |
# A list of default architectures that will be built
IMAGE_ARCH="amd64 arm32v7 arm64v8"
COMMIT_SHA=$(git log -1 --pretty=format:"%H")
LATEST_TAG_SHA=$(git rev-list --tags --max-count=1)
for THIS_ARCH in ${IMAGE_ARCH}; do
# Build image
docker build -t $DOCKER_USERNAME/$IMAGE_NAME:$THIS_ARCH \
-f docker/$THIS_ARCH-Dockerfile .
if [ $COMMIT_SHA == $LATEST_TAG_SHA ]; then
docker tag $DOCKER_USERNAME/$IMAGE_NAME:$THIS_ARCH $DOCKER_USERNAME/$IMAGE_NAME:$THIS_ARCH-$(git describe --abbrev=0 --tags)
fi
done
docker push $DOCKER_USERNAME/$IMAGE_NAME
docker manifest create $DOCKER_USERNAME/$IMAGE_NAME:latest $DOCKER_USERNAME/$IMAGE_NAME:amd64 $DOCKER_USERNAME/$IMAGE_NAME:arm32v7 $DOCKER_USERNAME/$IMAGE_NAME:arm64v8
docker manifest inspect $DOCKER_USERNAME/$IMAGE_NAME:latest
docker manifest push $DOCKER_USERNAME/$IMAGE_NAME:latest
if [ $COMMIT_SHA == $LATEST_TAG_SHA ]; then
TAG=$(git describe --abbrev=0 --tags)
docker manifest create $DOCKER_USERNAME/$IMAGE_NAME:$TAG $DOCKER_USERNAME/$IMAGE_NAME:amd64 $DOCKER_USERNAME/$IMAGE_NAME:arm32v7 $DOCKER_USERNAME/$IMAGE_NAME:arm64v8
docker manifest inspect $DOCKER_USERNAME/$IMAGE_NAME:$TAG
docker manifest push $DOCKER_USERNAME/$IMAGE_NAME:$TAG
fi