From 3e4e0c83585e0f0455c8f260cff9671a2e806808 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 10 Apr 2019 12:41:33 +0200 Subject: [PATCH] Improve the installation procedure --- .docker/nuth.sh | 9 +++++++++ Dockerfile | 14 ++++++++++---- docker-compose.yml | 2 ++ scripts/install.sh | 42 +++++++++++++++++++++++++++++------------- 4 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 .docker/nuth.sh diff --git a/.docker/nuth.sh b/.docker/nuth.sh new file mode 100644 index 0000000..709976d --- /dev/null +++ b/.docker/nuth.sh @@ -0,0 +1,9 @@ +#!/bin/bash +until nc -z db 3306 +do + >&2 echo "mysql is unavailable - waiting" + sleep 1 +done + +sudo -u www-data ../app/scripts/install.sh +apache2-foreground \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1134a3c..6806883 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM php:7.1.27-apache +FROM php:7.2.17-apache +COPY .docker/nuth.sh /usr/local/bin/nuth-start RUN chown -R www-data:www-data /var/www RUN apt update -y @@ -8,6 +9,8 @@ RUN apt install --no-install-recommends -y \ libtidy-dev \ libzip-dev \ mysql-client \ + netcat \ + rsync \ sudo \ unzip \ zip @@ -36,10 +39,13 @@ RUN mv composer.phar /usr/local/bin/composer COPY --chown=www-data:www-data ./composer.* ./ RUN sudo -u www-data mkdir public RUN sudo -u www-data composer install - -COPY --chown=www-data:www-data .docker/.env .env +RUN ./vendor/bin/sake installsake COPY .docker/xdebug.ini $PHP_INI_DIR/conf.d/ COPY .docker/date.ini $PHP_INI_DIR/conf.d/ -COPY --chown=www-data:www-data ./ ./ + +COPY --chown=www-data:www-data .docker/.env .env +COPY --chown=www-data:www-data ./ ../app RUN sudo -u www-data composer vendor-expose + +CMD [ "nuth-start" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d83b25d..053694d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,8 @@ services: - nuth ports: - 8000:80 + depends_on: + - db db: image: mysql:5 networks: diff --git a/scripts/install.sh b/scripts/install.sh index a2505ca..b57daea 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,24 +1,40 @@ #!/bin/bash -cd $(dirname $0) -cd .. +destinationDir=$(pwd) tempDir=$(mktemp -d) sourceDir="." -find $sourceDir \ +cd $(dirname $0) +cd .. + +rsync -a --delete $sourceDir/ $tempDir + +# Cleaning up the built website +find $tempDir \ + -mindepth 1 -and \ -name "*" -and \ -not \( \ \( \ - -path "$sourceDir/app" \ - -path "$sourceDir/public" \ - -path "$sourceDir/vendor" \ - -path "$sourceDir/themes" \ + -path "$tempDir/app" -or \ + -path "$tempDir/public" -or \ + -path "$tempDir/themes" \ \) \ -prune \ \) -and \ - -not -name ".env" -and \ - -not -name ".htaccess" \ - -print + -not -name ".htaccess" -and \ + -not -name "composer.*" \ + -exec rm -rf {} + -rsync -a --delete $sourceDir $tempDir -rsync -a --delete $tempDir/ . -rm -rf $tempDir \ No newline at end of file +# Cleaning up the destination directory +find $destinationDir \ + -mindepth 1 -and \ + -name "*" -and \ + -not -name ".env" \ + -exec rm -rf {} + + +# Copying the built website to the destination +rsync -a $tempDir/ $destinationDir + +# Installing the website +cd $destinationDir +composer install +./vendor/bin/sake dev/build \ No newline at end of file