Open mitra42 opened 3 years ago
Brian ( @justledbetter ) - something odd with membership, as I don't seem to be able to assign this task to you. Are you a member, or whatever github calls them, of this repo ? I'm going to assign to @jmday for now, because it was Jamison who merged the PRs
@mitra42 : The following check_for_updates.sh
file is used on our deployment servers (dev for now, eventually prod) to get the updated github changes each 5min:
$ cat check_for_updates.sh
#!/bin/sh
##
## BCL: Modified script to run _once_ so it can be called from Cron.
##
## Note:
## - I've added a docker Volume to contain persistent application data
## - I've added the ec2-user account to the docker group to allow it to run the docker command.
##
# This script polls a git repo for changes,
# if changes are found, it pulls them down, rebuilds, and restart the docker container
# This script executes an infinite loop that sleeps every 5 seconds
# Run the script with $nohup so it executes as a background using following command:
# $nohup ./container-cicd.sh > container-cicd.log &
cloneRepoDirectory=/home/ec2-user/bct-server
#move into cloned git repo directory
cd $cloneRepoDirectory
# find local and remote revision ids
git fetch
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse @{u})
# check if local and remote revision ids don't match
if [ $LOCAL != $REMOTE -o "x$1" != x ]; then
echo "GIT repo updated, upgrading Docker container"
echo "pulling new changes from repo"
#git pull origin master
git pull origin develop
echo "building new docker image"
sudo docker build --tag bct-server:latest .
echo "getting rid of currently running container"
sudo docker stop bct-server
sudo docker rm bct-server
echo "running new image in a new container"
sudo docker run -d \
-p 5000:5000 \
--name bct-server \
-v bct-server-appdata:/data \
-v bct-server-vol:/app \
bct-server:latest
fi
Creating the docker volume with the line:
-v bct-server-appdata:/data \
allows a persistent docker volume to be used for the /data directory in the docker container. Since other processes may use the /tmp directory, it seems a directory such as /data (or something else other than /tmp ?) would be advisable as a default.
Totally with you on the mkdir -p /data
. Good catch. I'll make the commit and PR on that for you to review.
Thanks - that file needs to be in the repo, along with modification of the README to point out how to install it in this environment.
Two questions about the recent pair of PR's #193 and #194
a) I think you want
mkdir -p /data
sincemkdir /data
will error if/data
already existsb) how is /tmp treated different from /data ? i.e. what steps are you taking to attach a new docker instance to an existing persistent volume.
I'm asking because I know when I do this kind of thing on kubernetes I have to - at the Kubernetes level - persist a volume (which by convention, at least archive.org, is
/pv
).