Fix appkey check + add helper

This commit is contained in:
thespad 2024-10-14 16:12:46 +01:00
parent 2c3eb82848
commit c84517086c
No known key found for this signature in database
4 changed files with 9 additions and 2 deletions

View File

@ -116,6 +116,7 @@ services:
- PGID=1000
- TZ=Etc/UTC
- APP_URL=
- APP_KEY=
- DB_HOST=
- DB_PORT=3306
- DB_USERNAME=
@ -138,6 +139,7 @@ docker run -d \
-e PGID=1000 \
-e TZ=Etc/UTC \
-e APP_URL= \
-e APP_KEY= \
-e DB_HOST= \
-e DB_PORT=3306 \
-e DB_USERNAME= \
@ -161,6 +163,7 @@ Containers are configured using parameters passed at runtime (such as those abov
| `-e PGID=1000` | for GroupID - see below for explanation |
| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). |
| `-e APP_URL=` | The IP:port or URL your application will be accessed on (ie. `http://192.168.1.1:6875` or `https://bookstack.mydomain.com` |
| `-e APP_KEY=` | Session encryption key. Can be generated with `docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey` |
| `-e DB_HOST=` | The database instance hostname |
| `-e DB_PORT=3306` | Database port (default `3306`) |
| `-e DB_USERNAME=` | Database user |

View File

@ -25,6 +25,7 @@ param_volumes:
param_usage_include_env: true
param_env_vars:
- { env_var: "APP_URL", env_value: "", desc: "The IP:port or URL your application will be accessed on (ie. `http://192.168.1.1:6875` or `https://bookstack.mydomain.com`"}
- { env_var: "APP_KEY", env_value: "", desc: "Session encryption key. Can be generated with `docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey`"}
- { env_var: "DB_HOST", env_value: "", desc: "The database instance hostname" }
- { env_var: "DB_PORT", env_value: "3306", desc: "Database port (default `3306`)" }
- { env_var: "DB_USERNAME", env_value: "", desc: "Database user" }

3
root/appkey Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
php /app/www/artisan key:generate --show

View File

@ -46,9 +46,9 @@ fi
# Check for app key
if [[ -z ${APP_KEY} ]]; then
if ! grep -qE "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env 2> /dev/null; then
if ! grep -qE "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env 2> /dev/null || grep -qE "APP_KEY=SomeRandomString" /app/www/.env 2> /dev/null; then
echo "An application key is missing, halting init!"
echo "You can generate a key with: docker exec -it bookstack php /app/www/artisan key:generate --show"
echo "You can generate a key with: docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey"
sleep infinity
fi
fi