Skip to content

Commit

Permalink
– Adds the ability to set the databank port via DB_PORT
Browse files Browse the repository at this point in the history
– Exposes all BookStack env variables to docker
– Adds LDAP to PHP
  • Loading branch information
dionysiusmarquis committed Sep 23, 2016
1 parent 91f3b9f commit 7da6f70
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ FROM php:7.0-apache
ENV BOOKSTACK=BookStack \
BOOKSTACK_VERSION=0.12.1

RUN apt-get update && apt-get install -y git zlib1g-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev wget \
RUN apt-get update && apt-get install -y git zlib1g-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev wget libldap2-dev \
&& docker-php-ext-install pdo pdo_mysql mbstring zip \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \
&& docker-php-ext-configure gd --with-freetype-dir=usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
&& cd /var/www && curl -sS https://getcomposer.org/installer | php \
Expand Down
52 changes: 36 additions & 16 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ if [ ! -f '/var/www/BookStack/.env' ]; then
cat > /var/www/BookStack/.env <<EOF
# Environment
APP_ENV=production
APP_DEBUG=false
APP_KEY=SomeRandomString
APP_DEBUG=${APP_DEBUG:-false}
APP_KEY=${APP_KEY:-SomeRandomString}
# Database details
DB_HOST=${DB_HOST:-localhost}
DB_PORT=${DB_PORT:-3306}
DB_DATABASE=${DB_DATABASE:-bookstack}
DB_USERNAME=${DB_USERNAME:-bookstack}
DB_PASSWORD=${DB_PASSWORD:-password}
Expand All @@ -32,24 +33,43 @@ if [ ! -f '/var/www/BookStack/.env' ]; then
MEMCACHED_SERVERS=127.0.0.1:11211:100
# Storage
STORAGE_TYPE=local
STORAGE_TYPE=${STORAGE_TYPE:-local}
# Amazon S3 Config
STORAGE_S3_KEY=false
STORAGE_S3_SECRET=false
STORAGE_S3_REGION=false
STORAGE_S3_BUCKET=false
STORAGE_S3_KEY=${STORAGE_S3_KEY:-false}
STORAGE_S3_SECRET=${STORAGE_S3_SECRET:-false}
STORAGE_S3_REGION=${STORAGE_S3_REGION:-false}
STORAGE_S3_BUCKET=${STORAGE_S3_BUCKET:-false}
# Storage URL
# Used to prefix image urls for when using custom domains/cdns
STORAGE_URL=false
STORAGE_URL=${STORAGE_URL:-false}
# General auth
AUTH_METHOD=standard
AUTH_METHOD=${AUTH_METHOD:-standard}
# Social Authentication information. Defaults as off.
GITHUB_APP_ID=false
GITHUB_APP_SECRET=false
GOOGLE_APP_ID=false
GOOGLE_APP_SECRET=false
GITHUB_APP_ID=${GITHUB_APP_ID:-false}
GITHUB_APP_SECRET=${GITHUB_APP_SECRET:-false}
GOOGLE_APP_ID=${GOOGLE_APP_ID:-false}
GOOGLE_APP_SECRET=${GOOGLE_APP_SECRET:-false}
# External services such as Gravatar
DISABLE_EXTERNAL_SERVICES=${DISABLE_EXTERNAL_SERVICES:-false}
# LDAP Settings
LDAP_SERVER=${LDAP_SERVER:-false}
LDAP_BASE_DN=${LDAP_BASE_DN:-false}
LDAP_DN=${LDAP_DN:-false}
LDAP_PASS=${LDAP_PASS:-false}
LDAP_USER_FILTER=${LDAP_USER_FILTER:-false}
LDAP_VERSION=${LDAP_VERSION:-false}
# Mail settings
MAIL_DRIVER=${MAIL_DRIVER:-smtp}
MAIL_HOST=${MAIL_HOST:-localhost}
MAIL_PORT=${MAIL_PORT:-1025}
MAIL_USERNAME=${MAIL_USERNAME:-null}
MAIL_PASSWORD=${MAIL_PASSWORD:-null}
MAIL_ENCRYPTION=${MAIL_ENCRYPTION:-null}
# URL used for social login redirects, NO TRAILING SLASH
EOF
else
Expand All @@ -59,10 +79,10 @@ EOF
fi
fi

echoerr wait-for-db: waiting for ${DB_HOST}:3306
echoerr wait-for-db: waiting for ${DB_HOST}:${DB_PORT}

timeout 15 bash <<EOT
while ! (echo > /dev/tcp/${DB_HOST}/3306) >/dev/null 2>&1;
while ! (echo > /dev/tcp/${DB_HOST}/${DB_PORT}) >/dev/null 2>&1;
do sleep 1;
done;
EOT
Expand All @@ -73,7 +93,7 @@ if [ $RESULT -eq 0 ]; then
sleep 1
echoerr wait-for-db: done
else
echoerr wait-for-db: timeout out after 15 seconds waiting for ${DB_HOST}:3306
echoerr wait-for-db: timeout out after 15 seconds waiting for ${DB_HOST}:${DB_PORT}
fi

cd /var/www/BookStack/ && php artisan key:generate && php artisan migrate --force
Expand Down

0 comments on commit 7da6f70

Please sign in to comment.