From 69cf33eb47c3d5df83dadb2558597ec70d0cf304 Mon Sep 17 00:00:00 2001 From: TBK Date: Thu, 25 Feb 2021 13:52:22 +0100 Subject: [PATCH] Entrypoint tweaks --- .env.example | 3 --- app/Dockerfile | 17 ++++++++++------- app/entrypoint.sh | 20 +++----------------- app/nginx.conf | 2 +- app/php.ini | 2 +- docker-compose.yml | 9 +++++---- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/.env.example b/.env.example index 236c542..1268b7a 100644 --- a/.env.example +++ b/.env.example @@ -7,9 +7,6 @@ APP_ENV=production APP_DEBUG=false APP_KEY=------------REPLACE_ME------------ -# Timezone -TZ=------------REPLACE_ME------------ - # The below url has to be set if using social auth options # or if you are not using BookStack at the root path of your domain. APP_URL=https://bookstackapp.com ------------REPLACE_ME------------ diff --git a/app/Dockerfile b/app/Dockerfile index 3eacddf..e8e2321 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -19,7 +19,7 @@ RUN set -ex \ && addgroup -S bookstack \ && adduser -S -D -H -s /sbin/nologin -G bookstack -g bookstack bookstack \ && apk update \ - && echo "Setting up PHP extensions" \ + && echo "Getting packages:" \ && apk add --no-cache \ curl \ multirun \ @@ -58,29 +58,32 @@ RUN set -ex \ composer \ && echo "Setting up PPM:" \ && mkdir -p /ppm/run \ + && chmod 0777 /ppm/run \ && cd /ppm \ - && chmod -R 777 run/ \ && composer require php-pm/php-pm:${PPM_VERSION} php-pm/httpkernel-adapter:${PPM_HTTP_VERSION} \ && chown www-data:www-data -R . \ - && echo "Get BookStack:" \ + && echo "Getting BookStack:" \ && mkdir -p ${BOOKSTACK_HOME} \ && cd ${BOOKSTACK_HOME} \ && curl -LJO https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz \ && tar --strip-components=1 -xzf BookStack-${BOOKSTACK_VERSION}.tar.gz \ && rm -rf ${BOOKSTACK}-${BOOKSTACK_VERSION}.tar.gz .env.example .env.example.complete .gitattributes .github .gitignore .travis.yml tests/ public/index.php \ && ln -s init.php bootstrap/autoload.php \ - && echo "Get Dependencies:" \ + && echo "Getting BookStack Dependencies:" \ && composer install \ && echo "Changing ownership:" \ && chown bookstack:bookstack -R . \ && echo "Setting folder permissions for www-data:" \ && chown www-data:bookstack -R bootstrap/cache public/uploads storage \ - && echo "Ensure www-data got access to Nginx folders:" \ + && echo "Ensuring www-data got access to Nginx folders:" \ && chown www-data:www-data -R /var/lib/nginx /var/log/nginx \ + && echo "Redirecting Nginx logs to stdout and stderr:" \ + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log \ && echo "Giving all system users access to multirun:" \ && chmod 0755 /usr/bin/multirun -USER www-data:www-data +USER www-data WORKDIR $BOOKSTACK_HOME @@ -88,4 +91,4 @@ EXPOSE 8080/tcp VOLUME ["$BOOKSTACK_HOME/public/uploads", "$BOOKSTACK_HOME/public/storage"] -ENTRYPOINT ["./entrypoint.sh"] +ENTRYPOINT ["multirun", "nginx", "./entrypoint.sh"] diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 99be78d..ccbfd96 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh set -ex -if [ ! -f /app/.env ]; then +if [ ! -f .env ]; then php artisan key:generate --no-interaction --force fi php artisan migrate --no-interaction --force @@ -9,19 +9,5 @@ php artisan migrate --no-interaction --force php artisan cache:clear php artisan view:clear -echo "Getting PPM ready:" -trapIt() { - "$@" & - pid="$!" - for SGNL in INT TERM CHLD USR1; do - trap "kill -$SGNL $pid" "$SGNL"; - done - while kill -0 $pid >/dev/null 2>&1; do - wait $pid - ec="$?" - done - exit $ec -} - -echo "Starting Nginx & PPM:" -multirun "nginx" "$( trapIt /ppm/vendor/bin/ppm start --ansi --no-interaction --config=ppm.json )" +echo "Starting PPM:" +/ppm/vendor/bin/ppm start --ansi --no-interaction --config=ppm.json diff --git a/app/nginx.conf b/app/nginx.conf index aa504cc..5361691 100644 --- a/app/nginx.conf +++ b/app/nginx.conf @@ -1,5 +1,5 @@ worker_processes auto; -pid /tmp/nginx.pid; +pid /tmp/nginx.pid; daemon on; events { diff --git a/app/php.ini b/app/php.ini index 3e5f431..7fd19a8 100644 --- a/app/php.ini +++ b/app/php.ini @@ -12,7 +12,7 @@ upload_max_filesize = 64M expose_php=0 session.save_handler = redis -session.save_path = "tcp://redis:6379?database=1" +session.save_path = "tcp://cache:6379?database=1" opcache.enable=1 opcache.enable_cli=1 diff --git a/docker-compose.yml b/docker-compose.yml index 005bfc7..935d777 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,11 @@ version: '3.7' + services: db: image: mariadb:10.5 restart: unless-stopped environment: - - TZ=${TZ} + - TZ=${APP_TIMEZONE} - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASS} - MYSQL_DATABASE=${DB_DATABASE} - MYSQL_USER=${DB_USERNAME} @@ -18,7 +19,7 @@ services: image: redis:6-alpine restart: unless-stopped environment: - - TZ=${TZ} + - TZ=${APP_TIMEZONE} volumes: - cache:/data/ networks: @@ -26,6 +27,7 @@ services: app: image: jjtc/bookstack-ppm:0.31.6-r0 + init: true build: ./app/ restart: unless-stopped depends_on: @@ -48,7 +50,6 @@ services: - "traefik.enable=true" - "traefik.http.routers.bookstack.entrypoints=http" - "traefik.http.routers.bookstack.rule=Host(`${APP_URL_BASE}`)" - - "traefik.http.routers.bookstack.middlewares=redirect-https@file" - "traefik.http.routers.bookstack-secure.entrypoints=https" - "traefik.http.routers.bookstack-secure.rule=Host(`${APP_URL_BASE}`)" - "traefik.http.routers.bookstack-secure.tls=true" @@ -72,7 +73,7 @@ services: # - "traefik.enable=false" #traefik: - # image: traefik:2.1 + # image: traefik:2.4 # restart: unless-stopped # security_opt: # - no-new-privileges:true