forked from lardbit/nefarious
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
42 lines (40 loc) · 2.09 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
dist: xenial
language: minimal
jobs:
include:
- stage: build default image and run unit tests
script:
- set -e
# create docker network to link containers
- docker network create tests
# run redis
- docker run --network tests --name redis --rm -d redis
# store commit in image for version identification
- echo "$TRAVIS_COMMIT" > src/.commit
# derive the docker image tag name from the git branch name
- if [[ $TRAVIS_BRANCH == 'master' ]]; then tag='latest'; else tag="$TRAVIS_BRANCH"; fi
# build image
- docker build -t lardbit/nefarious:$tag .
# run unit tests
- docker run --network tests -e REDIS_HOST=redis --entrypoint /env/bin/python lardbit/nefarious:$tag manage.py test
# authenticate with docker
- echo "$DOCKER_PASSWORD" | docker login -u "lardbit" --password-stdin
# push image to docker hub
- docker push lardbit/nefarious:$tag
- stage: build ARM image
script:
- set -e
# store commit in image for version identification
- echo "$TRAVIS_COMMIT" > src/.commit
# derive the docker ARM image tag name from the git branch name
- if [[ $TRAVIS_BRANCH == 'master' ]]; then tag='armv7'; else tag="armv7-$TRAVIS_BRANCH"; fi
# define the image tag to copy the image app in the build phase
- if [[ $TRAVIS_BRANCH == 'master' ]]; then copy_from_tag='latest'; else copy_from_tag="$TRAVIS_BRANCH"; fi
# build ARM image copying the app from the previously built base image
# NOTE: using "travis_wait" which produces output every minute to prevent the build from timing out
# https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
- travis_wait 30 docker build -f Dockerfile-armv7 --build-arg copy_from_tag=$copy_from_tag -t lardbit/nefarious:$tag .
# authenticate with docker
- echo "$DOCKER_PASSWORD" | docker login -u "lardbit" --password-stdin
# push ARM image to docker hub
- docker push lardbit/nefarious:$tag