forked from greenelab/old-adage-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.sh
45 lines (36 loc) · 1.39 KB
/
push.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
39
40
41
42
43
44
45
#!/bin/bash
# Avoid silent and/or consumed failures within a bash script.
# if interested: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# REMOTE=example.ecr.us-west-2.amazonaws.com
NAME=greenescientist/adageserver
HASH=$(git rev-parse HEAD)
#eval $(aws ecr get-login)
# Push same image twice, once with the commit hash as the tag, and once with
# 'latest' as the tag. 'latest' will always refer to the last image that was
# built, since the next time this script is run, it'll get overridden. The
# commit hash, however, is a constant reference to this image.
#docker tag -f $NAME $REMOTE/$NAME:$HASH
#docker push $REMOTE/$NAME:$HASH
#docker tag -f $NAME $REMOTE/$NAME:latest
#docker push $REMOTE/$NAME:latest
#docker logout https://$REMOTE
docker login --username=$DOCKER_USER --password=$DOCKER_PASSWD \
--email=$DOCKER_EMAIL
# Flag --email has been deprecated, will be removed in 1.13. CircleCI Still
# requires this.
# Don't need $REMOTE for docker hub but we'll want it later.
docker tag $NAME $NAME:$HASH
docker push $NAME:$HASH
# CircleCI Docker is old enough that -f is required here. It will break
# locally though. So only use in the CIRCLECI environment. One day we will
# have to remove this when CircleCI updates Docker.
if [ $CIRCLECI ]
then
docker tag -f $NAME $NAME:latest
else
docker tag $NAME $NAME:latest
fi
docker push $NAME:latest
docker logout