From b525568b72af71041cb181841587ef8926f729ee Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Thu, 25 Jun 2015 10:23:06 +0000 Subject: [PATCH 1/4] Beta test of pull and push scripts --- Dockerfile | 6 ++++++ pull | 18 ++++++++++++++++++ push | 20 ++++++++++++++++++++ start.sh | 8 ++++++++ 4 files changed, 52 insertions(+) create mode 100755 pull create mode 100755 push diff --git a/Dockerfile b/Dockerfile index 0aea5b8..df6ae06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,6 +63,12 @@ RUN ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/defau ADD ./index.php /usr/share/nginx/html/index.php RUN chown -Rf nginx.nginx /usr/share/nginx/html/ +# Add git commands to allow container updating +ADD ./pull /usr/bin/pull +ADD ./push /usr/bin/push +RUN chmod 755 /usr/bin/pull +RUN chmod 755 /usr/bin/push + # Supervisor Config RUN /usr/bin/easy_install supervisor RUN /usr/bin/easy_install supervisor-stdout diff --git a/pull b/pull new file mode 100755 index 0000000..e73eab4 --- /dev/null +++ b/pull @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$GIT_EMAILi2" ]; then + echo "You need to pass the \$GIT_EMAIL variable to the container for this to work" + exit +else + echo $GIT_EMAIL +fi + +if [ -z "$GIT_NAME" ]; then + echo "You need to pass the \$GIT_NAME variable to the container for this to work" + exit +else + echo $GIT_NAME +fi + +cd /usr/share/nginx/html +git pull diff --git a/push b/push new file mode 100755 index 0000000..3f2eb0a --- /dev/null +++ b/push @@ -0,0 +1,20 @@ +#!/bin/bash + +timestamp() { + date +"%D %T" +} + +if [ -z "$GIT_EMAIL" ]; then + echo "You need to pass the \$GIT_EMAIL variable to the container for this to work" + exit +fi + +if [ -z "$GIT_NAME" ]; then + echo "You need to pass the \$GIT_NAME variable to the container for this to work" + exit +fi + +ts=$(timestamp) +cd /usr/share/nginx/html +git add * +git commit -a -m "push from container $ts" diff --git a/start.sh b/start.sh index 0781b1d..14c575e 100644 --- a/start.sh +++ b/start.sh @@ -5,6 +5,14 @@ mkdir -p -m 0700 /root/.ssh echo -e "Host *\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config +# Setup git variables +if [ ! -z "$GIT_EMAIL" ]; then + git config --global user.email "$GIT_EMAIL" +fi +if [ ! -z "$GIT_NAME" ]; then + git config --global user.name "$GIT_NAME" +fi + # Pull down code form git for our site! if [ ! -z "$GIT_REPO" ]; then rm /usr/share/nginx/html/* From d34afc56e0bf7cf1bc56f3349df38d3ec396841c Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Thu, 25 Jun 2015 11:07:16 +0000 Subject: [PATCH 2/4] fixing syntax in pull script --- pull | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull b/pull index e73eab4..2f1c06f 100755 --- a/pull +++ b/pull @@ -1,6 +1,6 @@ #!/bin/bash -if [ -z "$GIT_EMAILi2" ]; then +if [ -z "$GIT_EMAIL" ]; then echo "You need to pass the \$GIT_EMAIL variable to the container for this to work" exit else From a3c11bb0677de2126128954c8b5f44672f963e0d Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Thu, 25 Jun 2015 13:05:43 +0000 Subject: [PATCH 3/4] Working Git scripts --- pull | 4 ---- push | 1 + start.sh | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pull b/pull index 2f1c06f..8a726da 100755 --- a/pull +++ b/pull @@ -3,15 +3,11 @@ if [ -z "$GIT_EMAIL" ]; then echo "You need to pass the \$GIT_EMAIL variable to the container for this to work" exit -else - echo $GIT_EMAIL fi if [ -z "$GIT_NAME" ]; then echo "You need to pass the \$GIT_NAME variable to the container for this to work" exit -else - echo $GIT_NAME fi cd /usr/share/nginx/html diff --git a/push b/push index 3f2eb0a..4fb06cb 100755 --- a/push +++ b/push @@ -18,3 +18,4 @@ ts=$(timestamp) cd /usr/share/nginx/html git add * git commit -a -m "push from container $ts" +git push diff --git a/start.sh b/start.sh index 14c575e..dd3a739 100644 --- a/start.sh +++ b/start.sh @@ -11,6 +11,7 @@ if [ ! -z "$GIT_EMAIL" ]; then fi if [ ! -z "$GIT_NAME" ]; then git config --global user.name "$GIT_NAME" + git config --global push.default simple fi # Pull down code form git for our site! From 96d30c6a5101e7fa49d125d3fb8a7928a6be5a3b Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Thu, 25 Jun 2015 13:15:30 +0000 Subject: [PATCH 4/4] Adding info for pull and push --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e77673b..30bac79 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,16 @@ sudo docker run -e 'GIT_REPO=git@git.ngd.io:ngineered/ngineered-website.git' -v ## Special Features +### Push code to Git +To push code changes back to git simply run: +``` +sudo docker exec -t -i /usr/bin/push +``` +### Pull code from Git (Refresh) +In order to refresh the code in a container and pull newer code form git simply run: +``` +sudo docker exec -t -i /usr/bin/pull +``` ### Templating This container will automatically configure your web application if you template your code. For example if you are linking to MySQL like above, and you have a config.php file where you need to set the MySQL details include $$_MYSQL_ENV_MYSQL_DATABASE_$$ style template tags.