From 32df06d2ab1a84430f5577c5cd4adb81f4554195 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 14 Oct 2021 16:03:09 -0500 Subject: [PATCH 1/2] Use standard nginx.conf from lsio alpine nginx base image --- Dockerfile | 64 +++++----- Dockerfile.aarch64 | 64 +++++----- Dockerfile.armhf | 64 +++++----- README.md | 1 + readme-vars.yml | 1 + root/defaults/default | 39 ------ root/defaults/nginx.conf | 98 --------------- .../nginx/site-confs/default.conf.sample | 40 ++++++ root/etc/cont-init.d/50-config | 114 ++++++++++-------- root/etc/services.d/php-fpm/run | 2 - root/var/www/html/public/index.html | 40 ++++++ 11 files changed, 249 insertions(+), 278 deletions(-) delete mode 100644 root/defaults/default delete mode 100644 root/defaults/nginx.conf create mode 100644 root/defaults/nginx/site-confs/default.conf.sample delete mode 100644 root/etc/services.d/php-fpm/run create mode 100644 root/var/www/html/public/index.html diff --git a/Dockerfile b/Dockerfile index 3f64736..7604f68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.14 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.15 # set version label ARG BUILD_DATE @@ -11,56 +11,62 @@ LABEL maintainer="homerr" ARG BOOKSTACK_RELEASE RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ + echo "**** install build packages ****" && \ + apk add --no-cache --virtual=build-dependencies \ + composer && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache \ curl \ - composer \ fontconfig \ memcached \ netcat-openbsd \ - php7-ctype \ - php7-curl \ - php7-dom \ - php7-gd \ - php7-ldap \ - php7-mbstring \ - php7-memcached \ - php7-mysqlnd \ - php7-openssl \ - php7-pdo_mysql \ - php7-phar \ - php7-simplexml \ - php7-tokenizer \ + php8-ctype \ + php8-curl \ + php8-dom \ + php8-gd \ + php8-ldap \ + php8-mbstring \ + php8-mysqlnd \ + php8-openssl \ + php8-pdo_mysql \ + php8-pecl-memcached \ + php8-phar \ + php8-simplexml \ + php8-tokenizer \ qt5-qtbase \ tar \ - ttf-freefont \ + ttf-freefont && \ + apk add --no-cache \ + --repository=http://dl-cdn.alpinelinux.org/alpine/v3.14/community \ wkhtmltopdf && \ - echo "**** configure php-fpm ****" && \ - sed -i 's/;clear_env = no/clear_env = no/g' /etc/php7/php-fpm.d/www.conf && \ - echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php7/php-fpm.conf && \ + echo "**** configure php-fpm to pass env vars ****" && \ + sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php8/php-fpm.d/www.conf && \ + grep -qxF 'clear_env = no' /etc/php8/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php8/php-fpm.d/www.conf && \ + echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php8/php-fpm.conf && \ echo "**** fetch bookstack ****" && \ mkdir -p\ - /var/www/html && \ + /app/www && \ if [ -z ${BOOKSTACK_RELEASE+x} ]; then \ BOOKSTACK_RELEASE=$(curl -sX GET "https://api.github.com/repos/bookstackapp/bookstack/releases/latest" \ | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi && \ curl -o \ - /tmp/bookstack.tar.gz -L \ + /tmp/bookstack.tar.gz -L \ "https://github.com/BookStackApp/BookStack/archive/${BOOKSTACK_RELEASE}.tar.gz" && \ tar xf \ - /tmp/bookstack.tar.gz -C \ - /var/www/html/ --strip-components=1 && \ + /tmp/bookstack.tar.gz -C \ + /app/www/ --strip-components=1 && \ echo "**** install composer dependencies ****" && \ - composer install -d /var/www/html/ && \ + composer install -d /app/www/ && \ echo "**** overlay-fs bug workaround ****" && \ - mv /var/www /var/www-tmp && \ + mv /app/www /app/www-tmp && \ echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ rm -rf \ /root/.composer \ /tmp/* COPY root/ / -VOLUME /config -EXPOSE 80 +EXPOSE 80 443 diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 3ae42f0..64a5837 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.14 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.15 # set version label ARG BUILD_DATE @@ -11,56 +11,62 @@ LABEL maintainer="homerr" ARG BOOKSTACK_RELEASE RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ + echo "**** install build packages ****" && \ + apk add --no-cache --virtual=build-dependencies \ + composer && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache \ curl \ - composer \ fontconfig \ memcached \ netcat-openbsd \ - php7-ctype \ - php7-curl \ - php7-dom \ - php7-gd \ - php7-ldap \ - php7-mbstring \ - php7-memcached \ - php7-mysqlnd \ - php7-openssl \ - php7-pdo_mysql \ - php7-phar \ - php7-simplexml \ - php7-tokenizer \ + php8-ctype \ + php8-curl \ + php8-dom \ + php8-gd \ + php8-ldap \ + php8-mbstring \ + php8-mysqlnd \ + php8-openssl \ + php8-pdo_mysql \ + php8-pecl-memcached \ + php8-phar \ + php8-simplexml \ + php8-tokenizer \ qt5-qtbase \ tar \ - ttf-freefont \ + ttf-freefont && \ + apk add --no-cache \ + --repository=http://dl-cdn.alpinelinux.org/alpine/v3.14/community \ wkhtmltopdf && \ - echo "**** configure php-fpm ****" && \ - sed -i 's/;clear_env = no/clear_env = no/g' /etc/php7/php-fpm.d/www.conf && \ - echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php7/php-fpm.conf && \ + echo "**** configure php-fpm to pass env vars ****" && \ + sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php8/php-fpm.d/www.conf && \ + grep -qxF 'clear_env = no' /etc/php8/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php8/php-fpm.d/www.conf && \ + echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php8/php-fpm.conf && \ echo "**** fetch bookstack ****" && \ mkdir -p\ - /var/www/html && \ + /app/www && \ if [ -z ${BOOKSTACK_RELEASE+x} ]; then \ BOOKSTACK_RELEASE=$(curl -sX GET "https://api.github.com/repos/bookstackapp/bookstack/releases/latest" \ | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi && \ curl -o \ - /tmp/bookstack.tar.gz -L \ + /tmp/bookstack.tar.gz -L \ "https://github.com/BookStackApp/BookStack/archive/${BOOKSTACK_RELEASE}.tar.gz" && \ tar xf \ - /tmp/bookstack.tar.gz -C \ - /var/www/html/ --strip-components=1 && \ + /tmp/bookstack.tar.gz -C \ + /app/www/ --strip-components=1 && \ echo "**** install composer dependencies ****" && \ - composer install -d /var/www/html/ && \ + composer install -d /app/www/ && \ echo "**** overlay-fs bug workaround ****" && \ - mv /var/www /var/www-tmp && \ + mv /app/www /app/www-tmp && \ echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ rm -rf \ /root/.composer \ /tmp/* COPY root/ / -VOLUME /config -EXPOSE 80 +EXPOSE 80 443 diff --git a/Dockerfile.armhf b/Dockerfile.armhf index a380eaa..ced74e8 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.14 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.15 # set version label ARG BUILD_DATE @@ -11,56 +11,62 @@ LABEL maintainer="homerr" ARG BOOKSTACK_RELEASE RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ + echo "**** install build packages ****" && \ + apk add --no-cache --virtual=build-dependencies \ + composer && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache \ curl \ - composer \ fontconfig \ memcached \ netcat-openbsd \ - php7-ctype \ - php7-curl \ - php7-dom \ - php7-gd \ - php7-ldap \ - php7-mbstring \ - php7-memcached \ - php7-mysqlnd \ - php7-openssl \ - php7-pdo_mysql \ - php7-phar \ - php7-simplexml \ - php7-tokenizer \ + php8-ctype \ + php8-curl \ + php8-dom \ + php8-gd \ + php8-ldap \ + php8-mbstring \ + php8-mysqlnd \ + php8-openssl \ + php8-pdo_mysql \ + php8-pecl-memcached \ + php8-phar \ + php8-simplexml \ + php8-tokenizer \ qt5-qtbase \ tar \ - ttf-freefont \ + ttf-freefont && \ + apk add --no-cache \ + --repository=http://dl-cdn.alpinelinux.org/alpine/v3.14/community \ wkhtmltopdf && \ - echo "**** configure php-fpm ****" && \ - sed -i 's/;clear_env = no/clear_env = no/g' /etc/php7/php-fpm.d/www.conf && \ - echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php7/php-fpm.conf && \ + echo "**** configure php-fpm to pass env vars ****" && \ + sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php8/php-fpm.d/www.conf && \ + grep -qxF 'clear_env = no' /etc/php8/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php8/php-fpm.d/www.conf && \ + echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php8/php-fpm.conf && \ echo "**** fetch bookstack ****" && \ mkdir -p\ - /var/www/html && \ + /app/www && \ if [ -z ${BOOKSTACK_RELEASE+x} ]; then \ BOOKSTACK_RELEASE=$(curl -sX GET "https://api.github.com/repos/bookstackapp/bookstack/releases/latest" \ | awk '/tag_name/{print $4;exit}' FS='[""]'); \ fi && \ curl -o \ - /tmp/bookstack.tar.gz -L \ + /tmp/bookstack.tar.gz -L \ "https://github.com/BookStackApp/BookStack/archive/${BOOKSTACK_RELEASE}.tar.gz" && \ tar xf \ - /tmp/bookstack.tar.gz -C \ - /var/www/html/ --strip-components=1 && \ + /tmp/bookstack.tar.gz -C \ + /app/www/ --strip-components=1 && \ echo "**** install composer dependencies ****" && \ - composer install -d /var/www/html/ && \ + composer install -d /app/www/ && \ echo "**** overlay-fs bug workaround ****" && \ - mv /var/www /var/www-tmp && \ + mv /app/www /app/www-tmp && \ echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ rm -rf \ /root/.composer \ /tmp/* COPY root/ / -VOLUME /config -EXPOSE 80 +EXPOSE 80 443 diff --git a/README.md b/README.md index 055ec00..2aa0dc2 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **20.08.22:** - Rebasing to alpine 3.15 with php8. Restructure nginx configs ([see changes announcement](https://info.linuxserver.io/issues/2022-08-20-nginx-base)). * **14.03.22:** - Add symlinks for theme support. * **11.07.21:** - Rebase to Alpine 3.14. * **12.01.21:** - Remove unused requirement, as of release 0.31.0. diff --git a/readme-vars.yml b/readme-vars.yml index 020d000..57fc1d5 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -101,6 +101,7 @@ app_setup_block: | # changelog changelogs: + - { date: "20.08.22:", desc: "Rebasing to alpine 3.15 with php8. Restructure nginx configs ([see changes announcement](https://info.linuxserver.io/issues/2022-08-20-nginx-base))." } - { date: "14.03.22:", desc: "Add symlinks for theme support." } - { date: "11.07.21:", desc: "Rebase to Alpine 3.14." } - { date: "12.01.21:", desc: "Remove unused requirement, as of release 0.31.0." } diff --git a/root/defaults/default b/root/defaults/default deleted file mode 100644 index da56e4c..0000000 --- a/root/defaults/default +++ /dev/null @@ -1,39 +0,0 @@ -## Version 2018/03/06 - Changelog: https://github.com/linuxserver/docker-heimdall/commits/master/root/defaults/default - -server { - listen 80 default_server; - - listen 443 ssl; - - root /var/www/html/public; - index index.php index.html index.htm; - - server_name _; - - ssl_certificate /config/keys/cert.crt; - ssl_certificate_key /config/keys/cert.key; - - client_max_body_size 0; - - error_page 599 = @noauth; - - location @noauth { - try_files $uri $uri/ /index.php?$args; - } - - location / { - try_files $uri $uri/ /index.php?$query_string; - - } - - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - # With php5-cgi alone: - fastcgi_pass 127.0.0.1:9000; - # With php5-fpm: - #fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; - include /etc/nginx/fastcgi_params; - - } -} diff --git a/root/defaults/nginx.conf b/root/defaults/nginx.conf deleted file mode 100644 index 70e8488..0000000 --- a/root/defaults/nginx.conf +++ /dev/null @@ -1,98 +0,0 @@ -user abc; -worker_processes 4; -pid /run/nginx.pid; -include /etc/nginx/modules/*.conf; - -events { - worker_connections 768; - # multi_accept on; -} - -http { - - ## - # Basic Settings - ## - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - # server_tokens off; - - # server_names_hash_bucket_size 64; - # server_name_in_redirect off; - - client_max_body_size 0; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - ## - # Logging Settings - ## - - access_log /config/log/nginx/access.log; - error_log /config/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - gzip_disable "msie6"; - - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; - - ## - # nginx-naxsi config - ## - # Uncomment it if you installed nginx-naxsi - ## - - #include /etc/nginx/naxsi_core.rules; - - ## - # nginx-passenger config - ## - # Uncomment it if you installed nginx-passenger - ## - - #passenger_root /usr; - #passenger_ruby /usr/bin/ruby; - - ## - # Virtual Host Configs - ## - include /etc/nginx/conf.d/*.conf; - include /config/nginx/site-confs/*; -} - - -#mail { -# # See sample authentication script at: -# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript -# -# # auth_http localhost/auth.php; -# # pop3_capabilities "TOP" "USER"; -# # imap_capabilities "IMAP4rev1" "UIDPLUS"; -# -# server { -# listen localhost:110; -# protocol pop3; -# proxy on; -# } -# -# server { -# listen localhost:143; -# protocol imap; -# proxy on; -# } -#} -daemon off; diff --git a/root/defaults/nginx/site-confs/default.conf.sample b/root/defaults/nginx/site-confs/default.conf.sample new file mode 100644 index 0000000..6840046 --- /dev/null +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -0,0 +1,40 @@ +## Version 2022/08/20 - Changelog: https://github.com/linuxserver/docker-bookstack/commits/master/root/defaults/nginx/site-confs/default.conf.sample + +server { + listen 80 default_server; + listen [::]:80 default_server; + + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name _; + + root /app/www/public; + index index.html index.htm index.php; + + error_page 599 = @noauth; + + location @noauth { + try_files $uri $uri/ /index.php?$args; + } + + location / { + # enable for basic auth + #auth_basic "Restricted"; + #auth_basic_user_file /config/nginx/.htpasswd; + + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ ^(.+\.php)(.*)$ { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + include /etc/nginx/fastcgi_params; + } + + # deny access to .htaccess/.htpasswd files + location ~ /\.ht { + deny all; + } +} diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 0b99a99..b3935db 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -1,9 +1,9 @@ #!/usr/bin/with-contenv bash -if [ -d /var/www-tmp ]; then +if [ -d /app/www-tmp ]; then echo "New container detected. Setting up app folder and fixing permissions." - mv /var/www-tmp /var/www - chown -R abc:abc /var/www + mv /app/www-tmp /app/www + chown -R abc:abc /app/www fi # create directory structure @@ -11,52 +11,53 @@ mkdir -p \ /config/www/{uploads,files,images,themes} # check for .env and copy default if needed -[[ ! -f "/config/www/.env" ]] && \ - cp /var/www/html/.env.example /config/www/.env - -# check for zero-length .env and alert user if found -[[ ! -s "/config/www/.env" ]] && \ - echo "WARNING: zero-length .env file detected. Please delete /config/www/.env and restart the container" +if [[ ! -f "/config/www/.env" ]] || [[ ! -s "/config/www/.env" ]]; then + cp /app/www/.env.example /config/www/.env +fi # create symlinks symlinks=( \ -/var/www/html/themes \ -/var/www/html/storage/uploads/files \ -/var/www/html/storage/uploads/images \ -/var/www/html/public/uploads \ -/var/www/html/.env \ -/var/www/html/storage/logs/laravel.log +/app/www/themes \ +/app/www/storage/uploads/files \ +/app/www/storage/uploads/images \ +/app/www/public/uploads \ +/app/www/.env \ +/app/www/storage/logs/laravel.log ) for i in "${symlinks[@]}" do -[[ -e "$i" && ! -L "$i" ]] && rm -rf "$i" -[[ ! -L "$i" ]] && ln -s /config/www/"$(basename "$i")" "$i" + if [[ -e "$i" && ! -L "$i" ]]; then + rm -rf "$i" + fi + if [[ ! -L "$i" ]]; then + ln -s /config/www/"$(basename "$i")" "$i" + fi done # Echo init finish for test runs if [ -n "${TEST_RUN}" ]; then - echo '[services.d] done.' + echo '[services.d] done.' 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) - 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" + then + echo "Generating BookStack app key for first run" + key=$(php /app/www/artisan key:generate --show) + 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) + then + echo "App Key found - setting variable for seds" + key=$(cat /config/BOOKSTACK_APP_KEY.txt) fi # .env file setup # check for the default app key or if it has been updated if grep -Fxq "APP_KEY=SomeRandomString" /config/www/.env || \ ! grep -Fxq "APP_KEY=${key}" /config/www/.env; then - sed -i "s#^APP_KEY=.*#APP_KEY=${key}#" /config/www/.env + sed -i "s#^APP_KEY=.*#APP_KEY=${key}#" /config/www/.env fi # check to see if db_user is set, if it is then run seds and if not then leave them if [ "${DB_USER}" ]; @@ -71,49 +72,58 @@ fi # set appurl if [ -z "${APP_URL}" ]; then - EXT_IP=$(curl -s https://icanhazip.com) - APP_URL="http://${EXT_IP}:6875" - echo "**** Docker env var APP_URL is not set, setting it to ${APP_URL} ****" + EXT_IP=$(curl -s https://icanhazip.com) + APP_URL="http://${EXT_IP}:6875" + echo "**** Docker env var APP_URL is not set, setting it to ${APP_URL} ****" fi OLD_URL=$(grep APP_URL /config/www/.env | sed 's|.*APP_URL=||g') if [ "${APP_URL}" != "${OLD_URL}" ]; then - sed -r "s,([#\s]*)?APP_URL=.*,APP_URL=${APP_URL},g" -i /config/www/.env - echo "**** APP_URL in /config/www/.env is being updated from ${OLD_URL} to ${APP_URL} ****" - if [ "${OLD_URL}" != "http://example.com" ]; then - echo "**** If this is an existing install, you should run the following line from your host terminal to update the database URL entries: ****" - echo "************************************************************************" - echo "docker exec -it bookstack php /var/www/html/artisan bookstack:update-url ${OLD_URL} ${APP_URL}" - echo "************************************************************************" - fi + sed -r "s,([#\s]*)?APP_URL=.*,APP_URL=${APP_URL},g" -i /config/www/.env + echo "**** APP_URL in /config/www/.env is being updated from ${OLD_URL} to ${APP_URL} ****" + if [ "${OLD_URL}" != "http://example.com" ]; then + echo "**** If this is an existing install, you should run the following line from your host terminal to update the database URL entries: ****" + echo "************************************************************************" + echo "docker exec -it bookstack php /app/www/artisan bookstack:update-url ${OLD_URL} ${APP_URL}" + echo "************************************************************************" + fi fi ## Bump php upload max filesize and post max size to 100MB by default -grep -qx '^upload_max_filesize.*$' /config/php/php-local.ini || echo 'upload_max_filesize = 100M' >> /config/php/php-local.ini -grep -qx '^post_max_size.*$' /config/php/php-local.ini || echo 'post_max_size = 100M' >> /config/php/php-local.ini +if ! grep -qx '^upload_max_filesize.*$' /config/php/php-local.ini; then + echo 'upload_max_filesize = 100M' >> /config/php/php-local.ini +fi +if ! grep -qx '^post_max_size.*$' /config/php/php-local.ini; then + echo 'post_max_size = 100M' >> /config/php/php-local.ini +fi # check for the mysql endpoint for 30 seconds END=$((SECONDS+30)) while [ ${SECONDS} -lt ${END} ] && [ -n "${DB_HOST+x}" ]; do - /usr/bin/nc -z ${DB_HOST} 3306 && \ - if [ ! -z "$(/usr/bin/nc -w1 ${DB_HOST} 3306)" ]; then - [ ! -z "${RUN}" ] && break - RUN="RAN" - # we sleep here again due to first run init on DB containers - [ ! -f /dbwait.lock ] && sleep 5 - else - sleep 1 - fi - sleep 1 + if /usr/bin/nc -z ${DB_HOST} 3306; then + if [ ! -z "$(/usr/bin/nc -w1 ${DB_HOST} 3306)" ]; then + if [ ! -z "${RUN}" ]; then + break + fi + RUN="RAN" + # we sleep here again due to first run init on DB containers + if [ ! -f /dbwait.lock ]; then + sleep 5 + fi + else + sleep 1 + fi + fi + sleep 1 done # update database - will set up database if fresh, or, migrate existing if [ -z "${CI_RUN+x}" ]; then - php /var/www/html/artisan migrate --force + php /app/www/artisan migrate --force fi # set permissions chown -R abc:abc \ - /config + /config # set lockfile to avoid DB waits for this specific container touch /dbwait.lock diff --git a/root/etc/services.d/php-fpm/run b/root/etc/services.d/php-fpm/run deleted file mode 100644 index 4e0812f..0000000 --- a/root/etc/services.d/php-fpm/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/with-contenv bash -exec /usr/sbin/php-fpm7 -F diff --git a/root/var/www/html/public/index.html b/root/var/www/html/public/index.html new file mode 100644 index 0000000..2ac31be --- /dev/null +++ b/root/var/www/html/public/index.html @@ -0,0 +1,40 @@ + + + Upgrade Required! + + + +
+

Upgrade Required!

+

The application inside this image has been moved to a new folder.

+

You will need to update your /config/nginx/nginx.conf and /config/nginx/site-confs/default.conf in order for the application to work.

+

New config samples are located at /config/nginx/nginx.conf.sample and /config/nginx/site-confs/default.conf.sample

+

Please review our announcement: Significant changes to nginx based images

+
+ + From ed2f423949beb04cec81c67b1ac8c9c0493b9296 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sat, 20 Aug 2022 18:53:43 -0500 Subject: [PATCH 2/2] Add default location migration --- root/migrations/02-default-location | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 root/migrations/02-default-location diff --git a/root/migrations/02-default-location b/root/migrations/02-default-location new file mode 100644 index 0000000..7f0e6f3 --- /dev/null +++ b/root/migrations/02-default-location @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash + +DEFAULT_CONF="/config/nginx/site-confs/default.conf" +OLD_ROOT="root /var/www/html/public;" +NEW_ROOT="root /app/www/public;" + +if grep -q "${OLD_ROOT}" "${DEFAULT_CONF}";then + echo "updating root in ${DEFAULT_CONF}" + sed -i "s|${OLD_ROOT}|${NEW_ROOT}|" "${DEFAULT_CONF}" +fi