From b8fc958111bbc17be767113097c302dda68f1001 Mon Sep 17 00:00:00 2001 From: Homer Date: Thu, 11 Oct 2018 06:43:29 +0100 Subject: [PATCH 01/10] the start --- Dockerfile | 2 ++ root/etc/cont-init.d/50-config | 8 ++++++++ root/etc/services.d/memcached/run | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 root/etc/services.d/memcached/run diff --git a/Dockerfile b/Dockerfile index aa7bdd4..e7c1d58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,12 @@ RUN \ echo "**** install build packages ****" && \ apk add --no-cache \ curl \ + memcached \ php7-ctype \ php7-dom \ php7-gd \ php7-mbstring \ + php7-memcached \ php7-mysqlnd \ php7-openssl \ php7-pdo_mysql \ diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index f7993a0..2ec0c41 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -16,6 +16,8 @@ do [[ ! -L "$i" ]] && ln -s /config/www/"$(basename "$i")" "$i" done +# .env file setup + # Check for ADVANCED_MODE to be set. If set, copy sample env file to /config and then copy to /var/www/html.env so advanced users can make their own customisations # If not set, runs in basic mode where .example.env is copied to /var/www/html/.env and seds are applied to set documented variables if [ "$ADVANCED_MODE" == 1 ]; @@ -45,6 +47,12 @@ if [ ! -z "$APP_URL" -a -z "$ADVANCED_MODE" ]; sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env fi +# email=1 set? let's do some more work +if [ ! -z "$USE_EMAIL" ]; + then + echo "Setting up email vars" + sed i "s\" + # Create API key if needed if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ] then diff --git a/root/etc/services.d/memcached/run b/root/etc/services.d/memcached/run new file mode 100644 index 0000000..a42215d --- /dev/null +++ b/root/etc/services.d/memcached/run @@ -0,0 +1,2 @@ +#!/usr/bin/with-contenv bash +exec memcache memcached From c3e008be30d2a9b2425fed6f6180625fbf1a04b8 Mon Sep 17 00:00:00 2001 From: Homer Date: Thu, 11 Oct 2018 17:21:11 +0100 Subject: [PATCH 02/10] more stuff --- Dockerfile.aarch64 | 2 ++ Dockerfile.armhf | 2 ++ Jenkinsfile | 4 +++- root/etc/cont-init.d/50-config | 18 ++++++++++++++---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 52fbb93..5900d47 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -16,10 +16,12 @@ RUN \ echo "**** install build packages ****" && \ apk add --no-cache \ curl \ + memcached \ php7-ctype \ php7-dom \ php7-gd \ php7-mbstring \ + php7-memcached \ php7-mysqlnd \ php7-openssl \ php7-pdo_mysql \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index e3c4e28..1d56ee2 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -16,10 +16,12 @@ RUN \ echo "**** install build packages ****" && \ apk add --no-cache \ curl \ + memcached \ php7-ctype \ php7-dom \ php7-gd \ php7-mbstring \ + php7-memcached \ php7-mysqlnd \ php7-openssl \ php7-pdo_mysql \ diff --git a/Jenkinsfile b/Jenkinsfile index 7189a22..2503fa2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,11 +17,13 @@ pipeline { BUILDS_DISCORD = credentials('build_webhook_url') GITHUB_TOKEN = credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab') DIST_IMAGE = 'alpine' - DIST_TAG = '3.7' + DIST_TAG = '3.8' DIST_PACKAGES = 'curl \ + memcached \ php7-openssl \ php7-pdo_mysql \ php7-mbstring \ + php7-memcached \ php7-tidy \ php7-phar \ php7-dom \ diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 2ec0c41..e2266ae 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -47,11 +47,21 @@ if [ ! -z "$APP_URL" -a -z "$ADVANCED_MODE" ]; sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env fi -# email=1 set? let's do some more work -if [ ! -z "$USE_EMAIL" ]; +# set up the application to use memcached + sed -i "s/CACHE_DRIVER=file/CACHE_DRIVER=memcached/g" + sed -i "s/SESSION_DRIVER=file/SESSION_DRIVER=memcached/g" + +# email username set? let's do some more work +if [ "$MAIL_USERNAME" -a -z "$ADVANCED_MODE" ]; then - echo "Setting up email vars" - sed i "s\" + echo "Setting up email vars. Check BookStack docs" + sed -i "s/MAIL_PORT=1025/MAIL_PORT=${MAIL_PORT}/g" + sed -i "s/MAIL_USERNAME=null/MAIL_USERNAME=${MAIL_USERNAME}/g" + sed -i "s/MAIL_PASSWORD=null/MAIL_PASSWORD=${MAIL_PASSWORD}/g" + sed -i "s/MAIL_ENCRYPTION=null/MAIL_ENCRYPTION=${MAIL_ENCRYPTION}/g" + sed -i "s/MAIL_FROM=null/MAIL_FROM=${MAIL_FROM}/g" + sed -i "s/MAIL_FROM_NAME=null/MAIL_FROM_NAME=${MAIL_FROM_NAME}/g" +fi # Create API key if needed if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ] From 1f9803fe62f0a0a2bedffcdf38edfea1f3169962 Mon Sep 17 00:00:00 2001 From: Homer Date: Thu, 11 Oct 2018 19:52:59 +0100 Subject: [PATCH 03/10] added mailserver --- root/etc/cont-init.d/50-config | 1 + 1 file changed, 1 insertion(+) diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index e2266ae..aa8c923 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -55,6 +55,7 @@ fi if [ "$MAIL_USERNAME" -a -z "$ADVANCED_MODE" ]; then echo "Setting up email vars. Check BookStack docs" + sed -i "s/MAIL_HOST=null/MAIL_HOST=${MAIL_HOST}/g" sed -i "s/MAIL_PORT=1025/MAIL_PORT=${MAIL_PORT}/g" sed -i "s/MAIL_USERNAME=null/MAIL_USERNAME=${MAIL_USERNAME}/g" sed -i "s/MAIL_PASSWORD=null/MAIL_PASSWORD=${MAIL_PASSWORD}/g" From 8cf0282e55064a369fec8ba3290ad4c1348a7bc7 Mon Sep 17 00:00:00 2001 From: homerr Date: Sun, 14 Oct 2018 20:34:56 +0100 Subject: [PATCH 04/10] simplification --- root/etc/cont-init.d/50-config | 46 +++++++--------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index aa8c923..932218f 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -2,7 +2,11 @@ # create directory structure mkdir -p \ - /config/www/{uploads,files,images} + /config/www/{html,uploads,files,images} + +# check for .env and copy default if needed +[[ ! -f "/config/.env" ]] && \ + cp /var/www/html/.env.example /config/www/html/.env # create symlinks symlinks=( \ @@ -17,53 +21,21 @@ do done # .env file setup - -# Check for ADVANCED_MODE to be set. If set, copy sample env file to /config and then copy to /var/www/html.env so advanced users can make their own customisations -# If not set, runs in basic mode where .example.env is copied to /var/www/html/.env and seds are applied to set documented variables -if [ "$ADVANCED_MODE" == 1 ]; +# check to see if db_user is set, if it is then run seds and if not then leave them +if [ "${DB_USER}" ]; then - echo "Advanced Mode Enabled - Syncing .env from /config to /var/www/html - if you're doing this you better read the BookStack documentation. Restart container after making changes to .env" - [[ ! -f "/config/.env" ]] && \ - cp /var/www/html/.env.example /config/.env - cp /config/.env /var/www/html/.env -elif [ -z "$ADVANCED_MODE" ]; - then - echo "Basic Mode Enabled - Using sed to set BookStack variables from Docker environment variables - check the docs" - cp /var/www/html/.env.example /var/www/html/.env - # set up .env + echo "Running config - db_user set" sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /var/www/html/.env sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env -else - echo "Nothing to do with .env - what did you do homer?" -fi - -# Check to see if appurl is set, and whether advanced mode is set. Will set .env APP_URL if variable present, and advanced mode not set -if [ ! -z "$APP_URL" -a -z "$ADVANCED_MODE" ]; +elif [ "${APP_URL}" ]; then echo "App URL Set" sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env fi -# set up the application to use memcached - sed -i "s/CACHE_DRIVER=file/CACHE_DRIVER=memcached/g" - sed -i "s/SESSION_DRIVER=file/SESSION_DRIVER=memcached/g" - -# email username set? let's do some more work -if [ "$MAIL_USERNAME" -a -z "$ADVANCED_MODE" ]; - then - echo "Setting up email vars. Check BookStack docs" - sed -i "s/MAIL_HOST=null/MAIL_HOST=${MAIL_HOST}/g" - sed -i "s/MAIL_PORT=1025/MAIL_PORT=${MAIL_PORT}/g" - sed -i "s/MAIL_USERNAME=null/MAIL_USERNAME=${MAIL_USERNAME}/g" - sed -i "s/MAIL_PASSWORD=null/MAIL_PASSWORD=${MAIL_PASSWORD}/g" - sed -i "s/MAIL_ENCRYPTION=null/MAIL_ENCRYPTION=${MAIL_ENCRYPTION}/g" - sed -i "s/MAIL_FROM=null/MAIL_FROM=${MAIL_FROM}/g" - sed -i "s/MAIL_FROM_NAME=null/MAIL_FROM_NAME=${MAIL_FROM_NAME}/g" -fi - # Create API key if needed if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ] then From d0c2648b2b55eaceb749bd2307e1cc389e113ed8 Mon Sep 17 00:00:00 2001 From: homerr Date: Sun, 14 Oct 2018 20:51:29 +0100 Subject: [PATCH 05/10] fixed paths --- .gitignore | 1 + root/etc/cont-init.d/50-config | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 96374c4..0e51313 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk +docker-compose.yml diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 932218f..1fd5d0d 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -2,17 +2,19 @@ # create directory structure mkdir -p \ - /config/www/{html,uploads,files,images} + /config/www/{uploads,files,images} # check for .env and copy default if needed -[[ ! -f "/config/.env" ]] && \ - cp /var/www/html/.env.example /config/www/html/.env +[[ ! -f "/config/www/.env" ]] && \ + cp /var/www/html/.env.example /config/www/.env # create symlinks symlinks=( \ /var/www/html/storage/uploads/files \ /var/www/html/storage/uploads/images \ -/var/www/html/public/uploads ) +/var/www/html/public/uploads \ +/var/www/html/.env +) for i in "${symlinks[@]}" do From 22d7ba78d39c0a07233916f5d1bd5c1ece03413b Mon Sep 17 00:00:00 2001 From: homerr Date: Mon, 15 Oct 2018 06:35:15 +0100 Subject: [PATCH 06/10] fixed paths --- root/etc/cont-init.d/50-config | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 1fd5d0d..3e31578 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -27,15 +27,15 @@ done if [ "${DB_USER}" ]; then echo "Running config - db_user set" - sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /var/www/html/.env - sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env - sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env - sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env - sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env + sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /config/www/.env + sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /config/www/.env + sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env + sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env + sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /config/www/.env elif [ "${APP_URL}" ]; then echo "App URL Set" - sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env + sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /config/www/.env fi # Create API key if needed From 634b55d7c358a5e495d61142be37e3a6733a5a50 Mon Sep 17 00:00:00 2001 From: Homer Date: Mon, 15 Oct 2018 09:37:13 +0100 Subject: [PATCH 07/10] changed appkey usage, moved appurl if, updated readme vars --- readme-vars.yml | 12 +++++------- root/etc/cont-init.d/50-config | 27 +++++++++++++++------------ root/etc/services.d/php-fpm/run | 1 - 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/readme-vars.yml b/readme-vars.yml index 52c74fa..caeea1d 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -30,7 +30,6 @@ param_env_vars: - { env_var: "DB_PASS", env_value: "", desc: "for specifying the database password" } - { env_var: "DB_DATABASE", env_value: "bookstackapp", desc: "for specifying the database to be used" } - { env_var: "APPURL", env_value: "your.site.here.xyz", desc: "for specifying the url your application will be accessed on "} - - { env_var: "ADVANCED_MODE", env_value: "1", desc: "enables advanced mode for direct editing of the .env - scroll down for details on this"} param_usage_include_ports: true param_ports: @@ -63,12 +62,10 @@ app_setup_block: | Documentation can be found at https://www.bookstackapp.com/docs/ - ### Advanced Mode - We have implemented a special 'advanced mode' where users who wish to leverage the built in SMTP or LDAP functionality, will have the ability to edit the .env by hand. With `ADVANCED_MODE=1` set when - the container is created, it will copy the .env.example to /config within the container. You can then edit this file on the host system (make sure you read the BookStack docs) and restart the - container when finished. When the container starts, it copies /config/.env to /var/www/html/.env within the container for the web app to use. It will do this every time the container restarts. - - Note, the APP_KEY is still set by PHP environment so you do not need to worrry about this. + ### Advanced Users + If you wish to use the extra functionality of BookStack such as email, memcache, ldap and so on you will need to make your own .env file with guidance from the BookStack documentation. + + When you create the container, do not set any arguements for SQL or APPURL. The container will copy an .env file to /config/www/.env on your host system for you to edit. ### Composer @@ -76,6 +73,7 @@ app_setup_block: | # changelog changelogs: + - { date: "15.10.18:", desc: "Changed functionality for advanced users"} - { date: "08.10.18:", desc: "Advanced mode, symlink changes, sed fixing, docs updated, added some composer files"} - { date: "23.09.28:", desc: "Updates pre-release"} - { date: "02.07.18:", desc: "Initial Release." } diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 3e31578..f16b982 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -22,6 +22,19 @@ do [[ ! -L "$i" ]] && ln -s /config/www/"$(basename "$i")" "$i" done +# Create API key if needed +if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ]; + then + echo "Generating BookStack app key for first run" + key=$(php /var/www/html/artisan key:generate --show | tr -d '//' ) + echo $key > /config/BOOKSTACK_APP_KEY.txt + echo "App Key set to $key you can modify the file to update /config/BOOKSTACK_APP_KEY.txt" +elif [ -f "/config/BOOKSTACK_APP_KEY.txt" ]; + then + echo "App Key found - setting variable for seds" + key=$(cat /config/BOOKSTACK_APP_KEY.txt) +fi + # .env file setup # check to see if db_user is set, if it is then run seds and if not then leave them if [ "${DB_USER}" ]; @@ -32,20 +45,10 @@ if [ "${DB_USER}" ]; sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /config/www/.env -elif [ "${APP_URL}" ]; - then - echo "App URL Set" - sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /config/www/.env fi -# Create API key if needed -if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ] - then - echo "Generating BookStack app key for first run" - key=$(php /var/www/html/artisan key:generate --show | tr -d '//' ) - echo $key > /config/BOOKSTACK_APP_KEY.txt - echo "App Key set to $key you can modify the file to update /config/BOOKSTACK_APP_KEY.txt" -fi +# set appurl if detected +[[ "${APP_URL}" ]] && sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /config/www/.env # update database - will set up database if fresh, or, migrate existing php /var/www/html/artisan migrate --force diff --git a/root/etc/services.d/php-fpm/run b/root/etc/services.d/php-fpm/run index 29ad5cb..4e0812f 100644 --- a/root/etc/services.d/php-fpm/run +++ b/root/etc/services.d/php-fpm/run @@ -1,3 +1,2 @@ #!/usr/bin/with-contenv bash -export APP_KEY=$(cat /config/BOOKSTACK_APP_KEY.txt) exec /usr/sbin/php-fpm7 -F From 744a40d1f5265e6fa0bc3ed0398172c1f9784f15 Mon Sep 17 00:00:00 2001 From: Homer Date: Mon, 15 Oct 2018 09:40:35 +0100 Subject: [PATCH 08/10] updated a var --- root/etc/cont-init.d/50-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index f16b982..1ebf583 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -40,7 +40,7 @@ fi if [ "${DB_USER}" ]; then echo "Running config - db_user set" - sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /config/www/.env + sed -i "s/APP_KEY=SomeRandomString/APP_KEY=${key}/g" /config/www/.env sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /config/www/.env sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env From 34fd324117b132d47ea5a0bdcea19b77ac61c904 Mon Sep 17 00:00:00 2001 From: Homer Date: Mon, 15 Oct 2018 09:52:33 +0100 Subject: [PATCH 09/10] memcache fix --- root/etc/services.d/memcached/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/services.d/memcached/run b/root/etc/services.d/memcached/run index a42215d..bd4a49e 100644 --- a/root/etc/services.d/memcached/run +++ b/root/etc/services.d/memcached/run @@ -1,2 +1,2 @@ #!/usr/bin/with-contenv bash -exec memcache memcached +exec memcached -u abc From 3ff047bfad0d337bcb2e4da5da226c4d64d5c1c8 Mon Sep 17 00:00:00 2001 From: Homer Date: Thu, 18 Oct 2018 15:17:51 +0100 Subject: [PATCH 10/10] change sed delimeter for old appkeys with / in them. symlink laravel log --- root/etc/cont-init.d/50-config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 1ebf583..a265435 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -13,7 +13,8 @@ symlinks=( \ /var/www/html/storage/uploads/files \ /var/www/html/storage/uploads/images \ /var/www/html/public/uploads \ -/var/www/html/.env +/var/www/html/.env \ +/var/www/html/storage/logs/laravel.log ) for i in "${symlinks[@]}" @@ -40,7 +41,7 @@ fi if [ "${DB_USER}" ]; then echo "Running config - db_user set" - sed -i "s/APP_KEY=SomeRandomString/APP_KEY=${key}/g" /config/www/.env + sed -i "s,APP_KEY=SomeRandomString,APP_KEY=${key},g" /config/www/.env sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /config/www/.env sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env