-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!groovy | ||
|
||
node { | ||
stage("Checkout") { | ||
checkout scm | ||
} | ||
stage("Build") { | ||
sh "docker-build.sh" | ||
} | ||
stage("Deploy") { | ||
sh "docker-service.sh" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker kill jareddlc_com &> /dev/null | ||
KILL=$? | ||
if [ $KILL -ne 0 ]; then | ||
echo "Docker kill failed" | ||
#exit $KILL | ||
fi | ||
|
||
docker rm jareddlc_com &> /dev/null | ||
RM=$? | ||
if [ $RM -ne 0 ]; then | ||
echo "Docker remove failed" | ||
#exit $RM | ||
fi | ||
|
||
docker build -t jareddlc.com . | ||
|
||
echo "Container: docker run -d --name jareddlc_com -p 80 jareddlc.com" | ||
echo "Service: docker service create --replicas 1 --name jareddlc_com -p 80 jareddlc.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker run -d --name jareddlc_com -p 80 jareddlc.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# Check to see if service is running | ||
output="$(docker service ls 2>/dev/null | grep jareddlc_com)" | ||
if [ -z "$output" ]; then | ||
echo "Docker service is not running. Creating docker service..." | ||
docker service create --replicas 1 --name jareddlc_com -p 80 jareddlc.com | ||
exit 0 | ||
fi | ||
echo "Docker service is running." | ||
|
||
# Check container id | ||
containerId=$(docker ps | grep jareddlc_com | awk '{print $1}') | ||
if [ -z "$containerId" ]; then | ||
echo "Docker container id not found" | ||
exit 1 | ||
fi | ||
|
||
# Kill the container to force docker service to create a new container | ||
echo "killing container id: $containerId" | ||
docker kill "$containerId" |