forked from jitendrabhalothia/DevOps_exercise_CI-CD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_app.sh
33 lines (25 loc) · 872 Bytes
/
deploy_app.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
#!/bin/bash
########################################
# Put this on a Server
# run chmod +x deploy_app.sh to make the script executable
#
# Execute this script: ./deploy_app.sh ariv3ra/python-circleci-docker:$TAG
# Replace the $TAG with the actual Build Tag you want to deploy
#
########################################
set -e
DOCKER_IMAGE=$1
CONAINER_NAME="hello_world"
# Check for arguments
if [[ $# -lt 1 ]] ; then
echo '[ERROR] You must supply a Docker Image to pull'
exit 1
fi
echo "Deploying Hello World to Docker Container"
#Check for running container & stop it before starting a new one
if [ $(docker inspect -f '{{.State.Running}}' $CONAINER_NAME) = "true" ]; then
docker stop hello_world
fi
echo "Starting Hello World using Docker Image name: $DOCKER_IMAGE"
docker run -d --rm=true -p 80:5000 --name hello_world $DOCKER_IMAGE
docker ps -a