From 67f51d0a3a8bb7181637b3c1aa428463e099cbc9 Mon Sep 17 00:00:00 2001 From: Jan <> Date: Thu, 16 Dec 2021 12:21:45 +0100 Subject: [PATCH 1/3] auto pulling from git repo --- DockerfilePullFromGit | 10 ++++++++++ README.md | 10 ++++++++++ gitpull.sh | 2 ++ install.sh | 23 +++++++++++++++++++++++ sui-cron | 2 ++ 5 files changed, 47 insertions(+) create mode 100755 DockerfilePullFromGit create mode 100644 gitpull.sh create mode 100644 install.sh create mode 100644 sui-cron diff --git a/DockerfilePullFromGit b/DockerfilePullFromGit new file mode 100755 index 0000000..898b803 --- /dev/null +++ b/DockerfilePullFromGit @@ -0,0 +1,10 @@ +FROM ubuntu:latest + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install nginx git cron nano + +COPY install.sh /tmp/ + +EXPOSE 80 + +# execute install, start cron and nginx +CMD chmod +x /tmp/install.sh && /tmp/install.sh && cron && nginx diff --git a/README.md b/README.md index 5ba434e..639a0d2 100755 --- a/README.md +++ b/README.md @@ -22,6 +22,16 @@ To run at a different port open edit docker-compose.yml: ports: - 4000:80 +#### Install pull from git variant: + + - refreshs source code every 5 minutes from master branch you provided - convenience feature for lacy devs + - `git clone` this repository + - build image `docker build -f DockerfilePullFromGit -t sui:latest .` + - run image with `docker run -e GITURL='https://x:ghp_x@github.com/jeroenpardon/sui.git' -p 8081:80 sui:latest` + - can be run also with a private repository by setting username:api-key@ in the url (see above example). Otherwise remove this part of the url. + + + ### Customization #### Changing color themes diff --git a/gitpull.sh b/gitpull.sh new file mode 100644 index 0000000..aa71e89 --- /dev/null +++ b/gitpull.sh @@ -0,0 +1,2 @@ +cd /var/www/html +git -C repo pull \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e75462d --- /dev/null +++ b/install.sh @@ -0,0 +1,23 @@ +cd /var/www/html +git clone $GITURL sui +mv sui/* . +rm -rf sui +echo "pulled update" + +# Copy hello-cron file to the cron.d directory +cp sui-cron /etc/cron.d/sui-cron + +# Give execution rights on the cron job +chmod 0644 /etc/cron.d/sui-cron + +# set pull script permissions +chmod +x gitpull.sh + +# Apply cron job +crontab /etc/cron.d/sui-cron + +# Create the log file to be able to run tail +touch /var/log/cron.log + +# configure nginx +echo "daemon off;" >> /etc/nginx/nginx.conf diff --git a/sui-cron b/sui-cron new file mode 100644 index 0000000..65bc07d --- /dev/null +++ b/sui-cron @@ -0,0 +1,2 @@ +*/1 * * * * /var/www/html/gitpull.sh >> /var/log/cron.log 2>&1 +# An empty line is required at the end of this file for a valid cron file. From eeef988d8fa320df418e101dd3fe67fbcb6fd3d9 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 16 Dec 2021 16:09:25 +0100 Subject: [PATCH 2/3] Update install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index e75462d..1c91950 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ cd /var/www/html git clone $GITURL sui +shopt -s dotglob mv sui/* . rm -rf sui echo "pulled update" From 8ceb1d5301bcaf2a8e5e108d895fc46b0c6aab27 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 16 Dec 2021 16:12:24 +0100 Subject: [PATCH 3/3] Update gitpull.sh --- gitpull.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitpull.sh b/gitpull.sh index aa71e89..e72aacc 100644 --- a/gitpull.sh +++ b/gitpull.sh @@ -1,2 +1,2 @@ cd /var/www/html -git -C repo pull \ No newline at end of file +git pull