Skip to content

Commit ebb7fe7

Browse files
committed
make APP_URL required, detect changes
1 parent 78f4a9e commit ebb7fe7

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ Compatible with docker-compose v2 schemas.
7575
version: "2"
7676
services:
7777
bookstack:
78-
image: linuxserver/bookstack
78+
image: ghcr.io/linuxserver/bookstack
7979
container_name: bookstack
8080
environment:
8181
- PUID=1000
8282
- PGID=1000
83+
- APP_URL=
8384
- DB_HOST=bookstack_db
8485
- DB_USER=bookstack
8586
- DB_PASS=<yourdbpass>
@@ -92,7 +93,7 @@ services:
9293
depends_on:
9394
- bookstack_db
9495
bookstack_db:
95-
image: linuxserver/mariadb
96+
image: ghcr.io/linuxserver/mariadb
9697
container_name: bookstack_db
9798
environment:
9899
- PUID=1000
@@ -115,11 +116,11 @@ docker run -d \
115116
--name=bookstack \
116117
-e PUID=1000 \
117118
-e PGID=1000 \
119+
-e APP_URL= \
118120
-e DB_HOST=<yourdbhost> \
119121
-e DB_USER=<yourdbuser> \
120122
-e DB_PASS=<yourdbpass> \
121123
-e DB_DATABASE=bookstackapp \
122-
-e APP_URL=http://your.site.here.xyz `#optional` \
123124
-p 6875:80 \
124125
-v /path/to/data:/config \
125126
--restart unless-stopped \
@@ -136,11 +137,11 @@ Container images are configured using parameters passed at runtime (such as thos
136137
| `-p 80` | will map the container's port 80 to port 6875 on the host |
137138
| `-e PUID=1000` | for UserID - see below for explanation |
138139
| `-e PGID=1000` | for GroupID - see below for explanation |
140+
| `-e APP_URL=` | for specifying the IP:port or URL your application will be accessed on (ie. `http://192.168.1.1:6875` or `https://bookstack.mydomain.com` |
139141
| `-e DB_HOST=<yourdbhost>` | for specifying the database host |
140142
| `-e DB_USER=<yourdbuser>` | for specifying the database user |
141143
| `-e DB_PASS=<yourdbpass>` | for specifying the database password |
142144
| `-e DB_DATABASE=bookstackapp` | for specifying the database to be used |
143-
| `-e APP_URL=http://your.site.here.xyz` | for specifying the url your application will be accessed on (required for correct operation of reverse proxy) |
144145
| `-v /config` | this will store any uploaded data on the docker host |
145146

146147
## Environment variables from files (Docker secrets)
@@ -183,14 +184,14 @@ The default username is admin@admin.com with the password of **password**, acces
183184
This application is dependent on a MySQL database be it one you already have or a new one. If you do not already have one, set up our MariaDB container here https://hub.docker.com/r/linuxserver/mariadb/.
184185

185186

186-
If you intend to use this application behind a subfolder reverse proxy, such as our LetsEncrypt container or Traefik you will need to make sure that the `APP_URL` environment variable is set, or it will not work
187+
If you intend to use this application behind a subfolder reverse proxy, such as our SWAG container or Traefik you will need to make sure that the `APP_URL` environment variable is set to your external domain, or it will not work
187188

188189
Documentation for BookStack can be found at https://www.bookstackapp.com/docs/
189190

190191
### Advanced Users (full control over the .env file)
191192
If you wish to use the extra functionality of BookStack such as email, Memcache, LDAP and so on you will need to make your own .env file with guidance from the BookStack documentation.
192193

193-
When you create the container, do not set any arguments for any SQL settings, or APP_URL. The container will copy an exemplary .env file to /config/www/.env on your host system for you to edit.
194+
When you create the container, do not set any arguments for any SQL settings. The container will copy an exemplary .env file to /config/www/.env on your host system for you to edit.
194195

195196
#### PDF Rendering
196197
[wkhtmltopdf](https://wkhtmltopdf.org/) is available to use as an alternative PDF rendering generator as described at https://www.bookstackapp.com/docs/admin/pdf-rendering/.
@@ -269,6 +270,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
269270

270271
## Versions
271272

273+
* **17.12.20:** - Make APP_URL var required (upstream changes).
272274
* **17.09.20:** - Rebase to alpine 3.12. Fix APP_URL setting. Bump php post max and upload max filesizes to 100MB by default.
273275
* **19.12.19:** - Rebasing to alpine 3.11.
274276
* **26.07.19:** - Use old version of tidyhtml pending upstream fixes.

readme-vars.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ param_volumes:
2525
- { vol_path: "/config", vol_host_path: "/path/to/data", desc: "this will store any uploaded data on the docker host" }
2626
param_usage_include_env: true
2727
param_env_vars:
28+
- { env_var: "APP_URL", env_value: "", desc: "for specifying the IP:port or URL your application will be accessed on (ie. `http://192.168.1.1:6875` or `https://bookstack.mydomain.com`"}
2829
- { env_var: "DB_HOST", env_value: "<yourdbhost>", desc: "for specifying the database host" }
2930
- { env_var: "DB_USER", env_value: "<yourdbuser>", desc: "for specifying the database user" }
3031
- { env_var: "DB_PASS", env_value: "<yourdbpass>", desc: "for specifying the database password" }
@@ -34,20 +35,20 @@ param_usage_include_ports: true
3435
param_ports:
3536
- { external_port: "6875", internal_port: "80", port_desc: "will map the container's port 80 to port 6875 on the host" }
3637

37-
opt_param_usage_include_env: true
38+
opt_param_usage_include_env: false
3839
opt_param_env_vars:
39-
- { env_var: "APP_URL", env_value: "http://your.site.here.xyz", desc: "for specifying the url your application will be accessed on (required for correct operation of reverse proxy)"}
4040

4141
custom_compose: |
4242
---
4343
version: "2"
4444
services:
4545
bookstack:
46-
image: linuxserver/bookstack
46+
image: ghcr.io/linuxserver/bookstack
4747
container_name: bookstack
4848
environment:
4949
- PUID=1000
5050
- PGID=1000
51+
- APP_URL=
5152
- DB_HOST=bookstack_db
5253
- DB_USER=bookstack
5354
- DB_PASS=<yourdbpass>
@@ -60,7 +61,7 @@ custom_compose: |
6061
depends_on:
6162
- bookstack_db
6263
bookstack_db:
63-
image: linuxserver/mariadb
64+
image: ghcr.io/linuxserver/mariadb
6465
container_name: bookstack_db
6566
environment:
6667
- PUID=1000
@@ -83,14 +84,14 @@ app_setup_block: |
8384
This application is dependent on a MySQL database be it one you already have or a new one. If you do not already have one, set up our MariaDB container here https://hub.docker.com/r/linuxserver/mariadb/.
8485
8586
86-
If you intend to use this application behind a subfolder reverse proxy, such as our LetsEncrypt container or Traefik you will need to make sure that the `APP_URL` environment variable is set, or it will not work
87+
If you intend to use this application behind a subfolder reverse proxy, such as our SWAG container or Traefik you will need to make sure that the `APP_URL` environment variable is set to your external domain, or it will not work
8788
8889
Documentation for BookStack can be found at https://www.bookstackapp.com/docs/
8990
9091
### Advanced Users (full control over the .env file)
9192
If you wish to use the extra functionality of BookStack such as email, Memcache, LDAP and so on you will need to make your own .env file with guidance from the BookStack documentation.
9293
93-
When you create the container, do not set any arguments for any SQL settings, or APP_URL. The container will copy an exemplary .env file to /config/www/.env on your host system for you to edit.
94+
When you create the container, do not set any arguments for any SQL settings. The container will copy an exemplary .env file to /config/www/.env on your host system for you to edit.
9495
9596
#### PDF Rendering
9697
[wkhtmltopdf](https://wkhtmltopdf.org/) is available to use as an alternative PDF rendering generator as described at https://www.bookstackapp.com/docs/admin/pdf-rendering/.
@@ -100,6 +101,7 @@ app_setup_block: |
100101
101102
# changelog
102103
changelogs:
104+
- { date: "17.12.20:", desc: "Make APP_URL var required (upstream changes)." }
103105
- { date: "17.09.20:", desc: "Rebase to alpine 3.12. Fix APP_URL setting. Bump php post max and upload max filesizes to 100MB by default." }
104106
- { date: "19.12.19:", desc: "Rebasing to alpine 3.11." }
105107
- { date: "26.07.19:", desc: "Use old version of tidyhtml pending upstream fixes." }

root/etc/cont-init.d/50-config

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,28 @@ if [ "${DB_USER}" ];
5757
sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /config/www/.env
5858
fi
5959

60-
# set appurl if detected
61-
[ -n "${APP_URL}" ] && sed -r "s,([#\s]*)?APP_URL=.*,APP_URL=${APP_URL},g" -i /config/www/.env
60+
# set appurl
61+
if [ -z "${APP_URL}" ]; then
62+
EXT_IP=$(curl -s https://icanhazip.com)
63+
APP_URL="http://${EXT_IP}:6875"
64+
echo "**** Docker env var APP_URL is not set, setting it to ${APP_URL} ****"
65+
fi
66+
OLD_URL=$(grep APP_URL /config/www/.env | sed 's|.*APP_URL=||g')
67+
if [ "${APP_URL}" != "${OLD_URL}" ]; then
68+
sed -r "s,([#\s]*)?APP_URL=.*,APP_URL=${APP_URL},g" -i /config/www/.env
69+
echo "**** APP_URL in /config/www/.env is being updated from ${OLD_URL} to ${APP_URL} ****"
70+
if [ "${OLD_URL}" != "http://example.com" ]; then
71+
echo "**** If this is an existing install, you should run the following line from your host terminal to update the database URL entries: ****"
72+
echo "************************************************************************"
73+
echo "docker exec -it bookstack php /var/www/html/artisan bookstack:update-url ${OLD_URL} ${APP_URL}"
74+
echo "************************************************************************"
75+
fi
76+
fi
6277

6378
## Bump php upload max filesize and post max size to 100MB by default
6479
grep -qx '^upload_max_filesize.*$' /config/php/php-local.ini || echo 'upload_max_filesize = 100M' >> /config/php/php-local.ini
6580
grep -qx '^post_max_size.*$' /config/php/php-local.ini || echo 'post_max_size = 100M' >> /config/php/php-local.ini
6681

67-
68-
## TODO: Remove this following bit by 12/19/2020
69-
# Remove erronously added configs post-init
70-
sed -i "s/^upload_max_filesize = 100MB$//g" /config/php/php-local.ini
71-
sed -i "s/^post_max_size = 100MB$//g" /config/php/php-local.ini
72-
7382
# check for the mysql endpoint for 30 seconds
7483
END=$((SECONDS+30))
7584
while [ ${SECONDS} -lt ${END} ] && [ -n "${DB_HOST+x}" ]; do

0 commit comments

Comments
 (0)