-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-docker-image.sh
34 lines (22 loc) · 1.04 KB
/
build-docker-image.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
#!/bin/bash
## Script for automating deployment of source code into Heroku
export DOCKER_HUB_REPO="willianmga"
export APPNAME="social-chat-front"
export DOCKER_HUB_USERNAME="willianmga"
export USERNAME="willian.bodnariuc@gmail.com"
export RELEASE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
# Packages source code
ng build --prod || { echo 'Failed to build project. Exiting.' ; exit 1; }
# Build, tag and push docker image
#docker login login --username=$DOCKER_HUB_USERNAME --password $DOCKER_HUB_TOKEN || { echo 'Failed to login to docker hub. Exiting.' ; exit 1; }
docker build -t $APPNAME:$RELEASE_VERSION -t $APPNAME:latest . || { echo 'Failed to build docker image. Exiting.' ; exit 1; }
docker tag $APPNAME:$RELEASE_VERSION $DOCKER_HUB_REPO/$APPNAME:$RELEASE_VERSION
docker tag $APPNAME:latest $DOCKER_HUB_REPO/$APPNAME:latest
docker push $DOCKER_HUB_REPO/$APPNAME:$RELEASE_VERSION
docker push $DOCKER_HUB_REPO/$APPNAME:latest
rm -rf $OUTPUT_PATH