From 71cf3cf5c19940de5f829247a47fc487f64dcd9f Mon Sep 17 00:00:00 2001 From: bunkerity Date: Tue, 13 Jul 2021 11:00:18 +0200 Subject: [PATCH] use local sources when building Docker image, add LOCAL_PHP and LOCAL_PHP_REMOTE to settings.json and fix pip bug related to removed working directory --- Dockerfile | 1 + helpers/install.sh | 26 +++++++++++++++++--------- settings.json | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index adc36af..3f29f9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM nginx:1.20.1-alpine +COPY . /tmp/bunkerized-nginx-docker COPY helpers/install.sh /tmp/install.sh RUN apk --no-cache add bash && \ chmod +x /tmp/install.sh && \ diff --git a/helpers/install.sh b/helpers/install.sh index 75fb225..a0db151 100755 --- a/helpers/install.sh +++ b/helpers/install.sh @@ -297,6 +297,7 @@ if [ "$OS" = "" ] ; then echo "[!] Unsupported Operating System" exit 1 fi +old_dir="${PWD}" # Create /tmp/bunkerized-nginx echo "[*] Prepare /tmp/bunkerized-nginx" @@ -307,8 +308,9 @@ do_and_check_cmd mkdir /tmp/bunkerized-nginx # Create /opt/bunkerized-nginx echo "[*] Prepare /opt/bunkerized-nginx" -if [ -e "/opt/bunkerized-nginx" ] ; then - do_and_check_cmd rm -rf /opt/bunkerized-nginx +if [ -d "/opt/bunkerized-nginx" ] ; then + echo "[!] Looks like bunkerized-nginx is already installed" + exit 1 fi do_and_check_cmd mkdir -p /opt/bunkerized-nginx/deps @@ -587,6 +589,7 @@ do_and_check_cmd chmod 744 /usr/lib/nginx/modules/* if [ "$OS" = "alpine" ] ; then apk del build > /dev/null 2>&1 fi +cd "$old_dir" cleanup echo "[*] Dependencies for bunkerized-nginx successfully installed !" @@ -614,11 +617,16 @@ elif [ "$OS" = "alpine" ] ; then fi # Clone the repo -echo "[*] Clone bunkerity/bunkerized-nginx" -#CHANGE_DIR="/tmp" do_and_check_cmd git_secure_clone https://github.com/bunkerity/bunkerized-nginx.git 09a2a4f9e531b93684b0916a5146091a818501d3 -# TODO : do a secure clone -CHANGE_DIR="/tmp" do_and_check_cmd git clone https://github.com/bunkerity/bunkerized-nginx.git -CHANGE_DIR="/tmp/bunkerized-nginx" do_and_check_cmd git checkout dev +if [ "$OS" != "alpine" ] ; then + echo "[*] Clone bunkerity/bunkerized-nginx" + #CHANGE_DIR="/tmp" do_and_check_cmd git_secure_clone https://github.com/bunkerity/bunkerized-nginx.git 09a2a4f9e531b93684b0916a5146091a818501d3 + # TODO : do a secure clone + CHANGE_DIR="/tmp" do_and_check_cmd git clone https://github.com/bunkerity/bunkerized-nginx.git + CHANGE_DIR="/tmp/bunkerized-nginx" do_and_check_cmd git checkout dev +# Docker build case : simply rename the sources +else + do_and_check_cmd mv /tmp/bunkerized-nginx-docker /tmp/bunkerized-nginx +fi # Install Python dependencies echo "[*] Install python dependencies" @@ -840,6 +848,6 @@ echo "[*] Download geoip DB" do_and_check_cmd /opt/bunkerized-nginx/scripts/geoip.sh # We're done -echo "[*] Remove temp files" -do_and_check_cmd rm -rf /tmp/bunkerized-nginx +cd "$old_dir" +cleanup echo "[*] bunkerized-nginx successfully installed !" diff --git a/settings.json b/settings.json index a6874d8..8cf1d54 100644 --- a/settings.json +++ b/settings.json @@ -1008,6 +1008,24 @@ "label": "Remote php path", "regex": "^/([A-Za-z0-9\\-]/?)*$", "type": "text" + }, + { + "context": "multisite", + "default": "", + "env": "LOCAL_PHP", + "id": "local-php", + "label": "local php", + "regex": "^([a-zA-Z\\-0-9\\_\\./])*$", + "type": "text" + }, + { + "context": "multisite", + "default": "/app", + "env": "LOCAL_PHP_PATH", + "id": "local-php-path", + "label": "Local php path", + "regex": "^/([A-Za-z0-9\\-]/?)*$", + "type": "text" } ] },