Entrypoint tweaks

This commit is contained in:
TBK 2021-02-25 13:52:22 +01:00
parent a4cbf7d5eb
commit 69cf33eb47
No known key found for this signature in database
GPG Key ID: 6D4FD19CB66C95EA
6 changed files with 20 additions and 33 deletions

View File

@ -7,9 +7,6 @@ APP_ENV=production
APP_DEBUG=false APP_DEBUG=false
APP_KEY=------------REPLACE_ME------------ APP_KEY=------------REPLACE_ME------------
# Timezone
TZ=------------REPLACE_ME------------
# The below url has to be set if using social auth options # 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. # or if you are not using BookStack at the root path of your domain.
APP_URL=https://bookstackapp.com ------------REPLACE_ME------------ APP_URL=https://bookstackapp.com ------------REPLACE_ME------------

View File

@ -19,7 +19,7 @@ RUN set -ex \
&& addgroup -S bookstack \ && addgroup -S bookstack \
&& adduser -S -D -H -s /sbin/nologin -G bookstack -g bookstack bookstack \ && adduser -S -D -H -s /sbin/nologin -G bookstack -g bookstack bookstack \
&& apk update \ && apk update \
&& echo "Setting up PHP extensions" \ && echo "Getting packages:" \
&& apk add --no-cache \ && apk add --no-cache \
curl \ curl \
multirun \ multirun \
@ -58,29 +58,32 @@ RUN set -ex \
composer \ composer \
&& echo "Setting up PPM:" \ && echo "Setting up PPM:" \
&& mkdir -p /ppm/run \ && mkdir -p /ppm/run \
&& chmod 0777 /ppm/run \
&& cd /ppm \ && cd /ppm \
&& chmod -R 777 run/ \
&& composer require php-pm/php-pm:${PPM_VERSION} php-pm/httpkernel-adapter:${PPM_HTTP_VERSION} \ && composer require php-pm/php-pm:${PPM_VERSION} php-pm/httpkernel-adapter:${PPM_HTTP_VERSION} \
&& chown www-data:www-data -R . \ && chown www-data:www-data -R . \
&& echo "Get BookStack:" \ && echo "Getting BookStack:" \
&& mkdir -p ${BOOKSTACK_HOME} \ && mkdir -p ${BOOKSTACK_HOME} \
&& cd ${BOOKSTACK_HOME} \ && cd ${BOOKSTACK_HOME} \
&& curl -LJO https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz \ && curl -LJO https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz \
&& tar --strip-components=1 -xzf BookStack-${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 \ && 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 \ && ln -s init.php bootstrap/autoload.php \
&& echo "Get Dependencies:" \ && echo "Getting BookStack Dependencies:" \
&& composer install \ && composer install \
&& echo "Changing ownership:" \ && echo "Changing ownership:" \
&& chown bookstack:bookstack -R . \ && chown bookstack:bookstack -R . \
&& echo "Setting folder permissions for www-data:" \ && echo "Setting folder permissions for www-data:" \
&& chown www-data:bookstack -R bootstrap/cache public/uploads storage \ && 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 \ && 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:" \ && echo "Giving all system users access to multirun:" \
&& chmod 0755 /usr/bin/multirun && chmod 0755 /usr/bin/multirun
USER www-data:www-data USER www-data
WORKDIR $BOOKSTACK_HOME WORKDIR $BOOKSTACK_HOME
@ -88,4 +91,4 @@ EXPOSE 8080/tcp
VOLUME ["$BOOKSTACK_HOME/public/uploads", "$BOOKSTACK_HOME/public/storage"] VOLUME ["$BOOKSTACK_HOME/public/uploads", "$BOOKSTACK_HOME/public/storage"]
ENTRYPOINT ["./entrypoint.sh"] ENTRYPOINT ["multirun", "nginx", "./entrypoint.sh"]

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
set -ex set -ex
if [ ! -f /app/.env ]; then if [ ! -f .env ]; then
php artisan key:generate --no-interaction --force php artisan key:generate --no-interaction --force
fi fi
php artisan migrate --no-interaction --force php artisan migrate --no-interaction --force
@ -9,19 +9,5 @@ php artisan migrate --no-interaction --force
php artisan cache:clear php artisan cache:clear
php artisan view:clear php artisan view:clear
echo "Getting PPM ready:" echo "Starting PPM:"
trapIt() { /ppm/vendor/bin/ppm start --ansi --no-interaction --config=ppm.json
"$@" &
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 )"

View File

@ -12,7 +12,7 @@ upload_max_filesize = 64M
expose_php=0 expose_php=0
session.save_handler = redis 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=1
opcache.enable_cli=1 opcache.enable_cli=1

View File

@ -1,10 +1,11 @@
version: '3.7' version: '3.7'
services: services:
db: db:
image: mariadb:10.5 image: mariadb:10.5
restart: unless-stopped restart: unless-stopped
environment: environment:
- TZ=${TZ} - TZ=${APP_TIMEZONE}
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASS} - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASS}
- MYSQL_DATABASE=${DB_DATABASE} - MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USER=${DB_USERNAME} - MYSQL_USER=${DB_USERNAME}
@ -18,7 +19,7 @@ services:
image: redis:6-alpine image: redis:6-alpine
restart: unless-stopped restart: unless-stopped
environment: environment:
- TZ=${TZ} - TZ=${APP_TIMEZONE}
volumes: volumes:
- cache:/data/ - cache:/data/
networks: networks:
@ -26,6 +27,7 @@ services:
app: app:
image: jjtc/bookstack-ppm:0.31.6-r0 image: jjtc/bookstack-ppm:0.31.6-r0
init: true
build: ./app/ build: ./app/
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
@ -48,7 +50,6 @@ services:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.bookstack.entrypoints=http" - "traefik.http.routers.bookstack.entrypoints=http"
- "traefik.http.routers.bookstack.rule=Host(`${APP_URL_BASE}`)" - "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.entrypoints=https"
- "traefik.http.routers.bookstack-secure.rule=Host(`${APP_URL_BASE}`)" - "traefik.http.routers.bookstack-secure.rule=Host(`${APP_URL_BASE}`)"
- "traefik.http.routers.bookstack-secure.tls=true" - "traefik.http.routers.bookstack-secure.tls=true"
@ -72,7 +73,7 @@ services:
# - "traefik.enable=false" # - "traefik.enable=false"
#traefik: #traefik:
# image: traefik:2.1 # image: traefik:2.4
# restart: unless-stopped # restart: unless-stopped
# security_opt: # security_opt:
# - no-new-privileges:true # - no-new-privileges:true