-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
86 lines (81 loc) · 4.15 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
# By ChoKaPeek, <amael.tardif@epita.fr>
# defaults
language: ruby
os:
- linux
dist: xenial
# for docker credentials storage
addons:
apt:
packages:
- pass
- rng-tools
# docker 18.06 doesn't contain experimental buildx, installing latest version
before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# travis encrypt --com PRIVATE_ENV="value" --add env.global
# Expected tag is v?.?-<name-of-image>_<image.tag>
env:
global:
- TAG="${TRAVIS_TAG%%-*}"
- TMP="${TRAVIS_TAG#*-}"
- IMAGE_TAG="${TMP#*_}"
- IMAGE_PATH="${TMP%%_*}"
- IMAGE_NAME=$(basename "$IMAGE_PATH")
- IMAGE="$IMAGE_NAME:$IMAGE_TAG"
- DK_OPT=""
- PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64
# DOCKER_USERNAME
- secure: "L3pJ38Wp5sJnXVuDEV63Omup4J2A5+/nmjnQWsYf6EA4HQGswcRaBWs+g2DEgWLabFuMnfClET/gH+6B8Mo/5SoPOLKa1bpmybmH5pH2dLS+PzFzFNaYvsyLsGEFA5VrYv3lgoXZvp+jlpmkLBUtbCrlnXvrjiALH+HCzlYGH7dXbmKwdSqRBlKONAmKnbEUisa4h+o7uw+x1uxGllIRwTpvOFaLd6xZdYB84YM03fmyOacpBzHZTIahiSYdeEYM3RG469zHe89Kjyczw0iHQFpRBp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Z+g1HhsKuyY+9iOX1td90Gf1biIs9ShU="
jobs:
include:
- stage: build
script:
- sh ci/enable-experimental.sh
- if [[ "$IMAGE_TAG" =~ ^.*squash$ ]]; then DK_OPT="$DK_OPT --squash"; fi
- echo "Image $IMAGE_NAME - $IMAGE_TAG - $IMAGE_PATH - Options $DK_OPT"
- docker build $DK_OPT --build-arg TAG="$IMAGE_TAG" -t "$IMAGE" "$IMAGE_PATH"
- docker images
- docker save -o built_image.tar "$IMAGE"
workspaces:
create:
name: ws1
paths:
- built_image.tar
- stage: deploy
script:
- sh ci/docker-credentials-helper.sh
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker load -i built_image.tar
- docker tag "$IMAGE" "$DOCKER_USERNAME/$IMAGE"
- docker push "$DOCKER_USERNAME/$IMAGE"
workspaces:
use: ws1
- stage: cross-build
script:
- sh ci/docker-credentials-helper.sh
- sh ci/enable-experimental.sh
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --name xbuilder --use
- docker buildx inspect --bootstrap
- |
if [[ "$IMAGE_TAG" =~ ^.*squash$ ]]; then
DK_OPT="$DK_OPT --file $IMAGE_PATH/Dockerfile_squash"
bash ci/squash-runs.sh $IMAGE_PATH
cat $IMAGE_PATH/Dockerfile_squash
fi
- echo "Image $IMAGE_NAME - $IMAGE_TAG - $IMAGE_PATH - Options $DK_OPT"
- docker buildx build $DK_OPT --progress plain --platform "$PLATFORMS" --build-arg TAG="$IMAGE_TAG" -t "$DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_TAG" --push "$IMAGE_PATH"
stages:
- name: cross-build
if: tag =~ /^.*(es-kuzzle|elasticsearch).*$/
- name: build
if: (tag IS present) AND NOT (tag =~ /^.*(es-kuzzle|elasticsearch).*$/)
- name: deploy
if: (tag IS present) AND NOT (tag =~ /^.*(es-kuzzle|elasticsearch).*$/)