-
Notifications
You must be signed in to change notification settings - Fork 7
/
.travis.yml
98 lines (97 loc) · 3.81 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
language: bash
services: docker
env:
- VERSION=3.6.10 VARIANT=stretch/port MODE=build
- VERSION=3.6.10 VARIANT=stretch/socket MODE=build
- VERSION=3.6 VARIANT=stretch/port MODE=build
- VERSION=3.6 VARIANT=stretch/socket MODE=build
- VERSION=3.7.7 VARIANT=stretch/port MODE=build
- VERSION=3.7.7 VARIANT=stretch/socket MODE=build
- VERSION=3.7 VARIANT=stretch/port MODE=build
- VERSION=3.7 VARIANT=stretch/socket MODE=build
- VERSION=3.8.2 VARIANT=buster/port MODE=build
- VERSION=3.8.2 VARIANT=buster/socket MODE=build
- VERSION=3.8 VARIANT=buster/port MODE=build
- VERSION=3.8 VARIANT=buster/socket MODE=build
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
install:
- git clone https://github.com/docker-library/official-images.git ~/official-images
before_script:
- |
(
[ ! "$MODE" == "build" ] || sudo apt-get -y install docker-ce
)
- docker version
- docker --version
- env | sort
- FOLDER="./bot"
- dockerfile_dir="python$VERSION/$VARIANT"
- slash='/'; image="luckydonald${slash}telegram-bot:python${VERSION}-${VARIANT//$slash/-}"
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
script:
- |
(
set -Eeuo pipefail
set -x
ls -lah .
ls -lah $FOLDER
ls -lah $FOLDER/*/
mkdir -p /var/lib/docker/tmp/
# build/pull
DATE=$(date +%Y-%m-%d)
if [ "$MODE" == "build" ] ; then
for image_name in \
"$image" \
"$image-$DATE-$TRAVIS_COMMIT" \
"$image-$DATE-$TRAVIS_COMMIT" \
"$image-$DATE" \
"$image-$TRAVIS_COMMIT" \
; do
travis_retry docker build --build-arg FOLDER="$FOLDER" --build-arg BASE_IMAGE_GIT_COMMIT="$TRAVIS_COMMIT" --build-arg BASE_IMAGE_GIT_MESSAGE="$TRAVIS_COMMIT_MESSAGE" --build-arg IMAGE_NAME="$image_name" -t $image_name -f $dockerfile_dir/Dockerfile .
done;
else
docker pull "$image"
fi
# test
# ~/official-images/test/run.sh --config ./test_config.sh "$image"
# push/ignore
if [ "$TRAVIS_BRANCH" == "master" -a "$MODE" == "build" ]; then
travis_retry docker push "$image"
travis_retry docker push "$image-$DATE"
travis_retry docker push "$image-$TRAVIS_COMMIT"
travis_retry docker push "$image-$DATE-$TRAVIS_COMMIT"
fi
# onbuild
onbuild_dir="$dockerfile_dir/onbuild"
if [ -d $onbuild_dir ]; then
onbuildFrom="$(awk 'toupper($1) == "FROM" { print $2; exit }' $onbuild_dir/Dockerfile)"
docker tag "$image" "$onbuildFrom"
# build/pull
if [ "$MODE" == "build" ] ; then
for image_name in \
"$image-onbuild" \
"$image-$DATE-onbuild" \
"$image-$TRAVIS_COMMIT-onbuild" \
"$image-$DATE-$TRAVIS_COMMIT-onbuild" \
; do
travis_retry docker build --build-arg FOLDER="$FOLDER" --build-arg BASE_IMAGE_GIT_COMMIT="$TRAVIS_COMMIT" --build-arg BASE_IMAGE_GIT_MESSAGE="$TRAVIS_COMMIT_MESSAGE" --build-arg IMAGE_NAME="$image_name" "$image" -t $image_name -f $dockerfile_dir/Dockerfile .
done;
else
docker pull "$image-onbuild"
fi
# tests
# ~/official-images/test/run.sh --config ./test_config.sh "$image-onbuild"
# push/ignore
if [ "$TRAVIS_BRANCH" == "master" -a "$MODE" == "build" ]; then
travis_retry docker push "$image-onbuild"
travis_retry docker push "$image-$TRAVIS_COMMIT-onbuild"
travis_retry docker push "$image-$DATE-onbuild"
travis_retry docker push "$image-$DATE-$TRAVIS_COMMIT-onbuild"
fi # travis
fi # onbuild
)
after_script:
- docker images