forked from elgalu/docker-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbefore_install_pull
executable file
·44 lines (35 loc) · 1.62 KB
/
before_install_pull
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
#!/usr/bin/env bash
# set -e: exit asap if a command exits with a non-zero status
# set -x: print each command right before it is executed
set -xe
echoerr() { printf "%s\n" "$*" >&2; }
# print error and exit
die () {
echoerr "ERROR: $1"
# if $2 is defined AND NOT EMPTY, use $2; otherwise, set to "150"
errnum=${2-133}
exit $errnum
}
docker --version || echo "WARN: No docker installed yet"
docker-compose --version || echo "WARN: No docker-compose installed yet"
[ "${TRAVIS_BUILD_NUMBER}" == "" ] && die "Need env var TRAVIS_BUILD_NUMBER to know where to pull from"
# We always need to login to docker to avoid: toomanyrequests
[ "${DOCKER_USERNAME}" == "" ] && die "Need env var DOCKER_USERNAME to pull from docker"
[ "${DOCKER_PASSWORD}" == "" ] && die "Need env var DOCKER_PASSWORD to pull from docker"
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
echo "Logged in to docker with user '${DOCKER_USERNAME}'"
if [[ ${TRAVIS_PULL_REQUEST_SLUG} != "" && \
${TRAVIS_PULL_REQUEST_SLUG} != ${TRAVIS_REPO_SLUG} && \
${TRAVIS_PULL_REQUEST} != "false" ]]; then
echo "WARN: External PRs are untrusted by default therefore we need can't reuse and pull the image so building it from scratch..."
# ./test/before_install_setup
./host-scripts/gen-scm-source.sh
docker build -t selenium .
docker tag selenium:latest elgalu/selenium:latest
else
docker pull elgalu/build_selenium:${TRAVIS_BUILD_NUMBER}
docker tag elgalu/build_selenium:${TRAVIS_BUILD_NUMBER} selenium:latest
docker tag elgalu/build_selenium:${TRAVIS_BUILD_NUMBER} elgalu/selenium:latest
fi
docker images selenium
docker images elgalu/selenium