-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-push.sh
42 lines (33 loc) · 1.07 KB
/
docker-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
#!/bin/bash
# inspiration: https://github.com/ShelterTechSF/askdarcel-web/blob/master/tools/docker-build.sh
set -ex
REPO="nirajgeorgian/account"
COMMIT=$CODEBUILD_RESOLVED_SOURCE_VERSION
if [[ -z "$COMMIT" ]]; then
COMMIT=$(git log -1 --format=%H)
fi
COMMIT=${COMMIT::8}
DOCKER_HOST="https://hub.docker.com/r/nirajgeorgian/account"
if [[ "$ACCOUNT_SVC_PROFILE" == "development" ]]; then
TAG="development"
elif [[ "$ACCOUNT_SVC_PROFILE" == "testing" ]]; then
TAG="testing"
elif [[ "$ACCOUNT_SVC_PROFILE" == "production" ]]; then
TAG="production"
elif [[ "$ACCOUNT_SVC_PROFILE" == "staging" ]]; then
TAG="staging"
fi
echo $TAG
echo $COMMIT
echo "Creating version.json..."
echo "{
\"commit\": \"$COMMIT\",
\"image\": \"$TAG\",
}" > ./scripts/version.json
echo "Building docker image..."
docker build -f scripts/docker/Dockerfile -t $REPO:$COMMIT .
docker tag $REPO:$COMMIT $REPO:$TAG
echo "Pushing docker image..."
docker push $REPO:$TAG
echo "Writing image definitions file..."
echo "[{\"name\":\"AccountService\",\"imageUri\":\"$REPO:$TAG\"}]" > ./scripts/imagedefinitions.json