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/*