-
Notifications
You must be signed in to change notification settings - Fork 530
/
docker_build_and_push_flavor.sh
executable file
·38 lines (32 loc) · 1.39 KB
/
docker_build_and_push_flavor.sh
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
#!/bin/bash -x
# Builds and pushes flavors
#
# ./docker_build_and_push_flavor.sh FLAVOR [DOCKERFILE_PATH] [BUILD PARAMS]
#
# Docker password is in a file /tmp/docker.pass
# because this script uses -x for build transparency
# but we don't want to leak passwords
set -e
FLAVOR="$1"
shift
DOCKERFILE_PATH=${1:-$FLAVOR/Dockerfile}
shift
DOCKER_BUILD_PARAMS="$@"
cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin
docker build --pull -t openresty:$FLAVOR -f $DOCKERFILE_PATH $DOCKER_BUILD_PARAMS .
if [[ "$TRAVIS_BRANCH" == "master" ]] ; then
cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin &&
docker tag openresty:$FLAVOR $DOCKER_ORG/openresty:$FLAVOR &&
docker push $DOCKER_ORG/openresty:$FLAVOR ;
fi
if [[ "$TRAVIS_TAG" ]] ; then
TRAVIS_TAG_BASE=$(echo -n "$TRAVIS_TAG" | sed 's/-[0-9]$//g') ;
if [[ ( "$TRAVIS_TAG_BASE" ) && ( "$TRAVIS_TAG_BASE" != "$TRAVIS_TAG" ) ]] ; then
cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin &&
docker tag openresty:$FLAVOR $DOCKER_ORG/openresty:$TRAVIS_TAG_BASE-$FLAVOR &&
docker push $DOCKER_ORG/openresty:$TRAVIS_TAG_BASE-$FLAVOR ;
fi ;
cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin &&
docker tag openresty:$FLAVOR $DOCKER_ORG/openresty:$TRAVIS_TAG-$FLAVOR &&
docker push $DOCKER_ORG/openresty:$TRAVIS_TAG-$FLAVOR ;
fi