Skip to content

Commit 4923380

Browse files
authored
Merge pull request #27 from thelamer/master
Rebase to Alpine 3.9, add MySQL init logic, fix app key bug
2 parents 2584005 + 1bdc308 commit 4923380

8 files changed

+100
-116
lines changed

Diff for: Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM lsiobase/nginx:3.8
1+
FROM lsiobase/nginx:3.9
22

33
# set version label
44
ARG BUILD_DATE
@@ -15,6 +15,7 @@ RUN \
1515
curl \
1616
tar \
1717
memcached \
18+
netcat-openbsd \
1819
php7-ctype \
1920
php7-curl \
2021
php7-dom \

Diff for: Dockerfile.aarch64

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM lsiobase/nginx:arm64v8-3.8
1+
FROM lsiobase/nginx:arm64v8-3.9
22

33
# set version label
44
ARG BUILD_DATE
@@ -15,6 +15,7 @@ RUN \
1515
curl \
1616
tar \
1717
memcached \
18+
netcat-openbsd \
1819
php7-ctype \
1920
php7-curl \
2021
php7-dom \

Diff for: Dockerfile.armhf

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM lsiobase/nginx:arm32v7-3.8
1+
FROM lsiobase/nginx:arm32v7-3.9
22

33
# set version label
44
ARG BUILD_DATE
@@ -15,6 +15,7 @@ RUN \
1515
curl \
1616
tar \
1717
memcached \
18+
netcat-openbsd \
1819
php7-ctype \
1920
php7-curl \
2021
php7-dom \

Diff for: README.md

+25-29
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ docker create \
6161
-e DB_USER=<yourdbuser> \
6262
-e DB_PASS=<yourdbpass> \
6363
-e DB_DATABASE=bookstackapp \
64-
-e APP_URL=your.site.here.xyz \
64+
-e APP_URL=your.site.here.xyz `#optional` \
6565
-p 6875:80 \
6666
-v <path to data>:/config \
6767
--restart unless-stopped \
@@ -83,16 +83,32 @@ services:
8383
environment:
8484
- PUID=1000
8585
- PGID=1000
86-
- DB_HOST=<yourdbhost>
87-
- DB_USER=<yourdbuser>
86+
- DB_HOST=bookstack_db
87+
- DB_USER=bookstack
8888
- DB_PASS=<yourdbpass>
8989
- DB_DATABASE=bookstackapp
90-
- APP_URL=your.site.here.xyz
9190
volumes:
9291
- <path to data>:/config
9392
ports:
9493
- 6875:80
9594
restart: unless-stopped
95+
depends_on:
96+
- bookstack_db
97+
bookstack_db:
98+
image: linuxserver/mariadb
99+
container_name: bookstack_db
100+
environment:
101+
- PUID=1000
102+
- PGID=1000
103+
- MYSQL_ROOT_PASSWORD=<yourdbpass>
104+
- TZ=Europe/London
105+
- MYSQL_DATABASE=bookstackapp
106+
- MYSQL_USER=bookstack
107+
- MYSQL_PASSWORD=<yourdbpass>
108+
volumes:
109+
- <path to data>:/config
110+
restart: unless-stopped
111+
96112
```
97113

98114
## Parameters
@@ -128,39 +144,18 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel
128144
&nbsp;
129145
## Application Setup
130146

131-
This application is dependent on an SQL database be it one you already have or a new one. If you do not already have one, set up our MariaDB container.
132-
133-
Once the MariaDB container is deployed, you can enter the following commands into the shell of the MariaDB container to create the user, password and database that the app will then use. Replace myuser/mypassword with your own data.
147+
Default username is [email protected] with password of **password**, access the container at http://dockerhost:6875.
134148

135-
**Note** this will allow any user with these credentials to connect to the server, it is not limited to localhost
149+
This application is dependent on an 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/.
136150

137-
```
138-
from shell on sql container:
139-
mysql -u root -p
140-
CREATE DATABASE bookstackapp;
141-
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword';
142-
GRANT ALL privileges ON `bookstackapp`.* TO 'myuser'@'%';
143-
FLUSH PRIVILEGES;
144-
```
145-
146-
Once you have completed these, you can then use the docker run command to create your BookStack container. Make sure you replace things such as <yourdbuser> with the correct data.
147-
148-
Then docker start bookstackapp to start the container. You should then be able to access the container at http://dockerhost:6875
149-
150-
Default username is [email protected] with password of **password**
151-
152-
If you intend to use this application behind a 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
151+
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
153152

154153
Documentation for BookStack can be found at https://www.bookstackapp.com/docs/
155154

156155
### Advanced Users (full control over the .env file)
157156
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.
158157

159-
When you create the container, do not set any arguments for any SQL settings, or APP_URL. The container will copy an .env file to /config/www/.env on your host system for you to edit.
160-
161-
### Composer
162-
163-
Some simple docker-compose files are included for you to get started with. You will still need to manually configure the SQL server, but the compose files will get the stack running for you.
158+
When you create the container, do not set any arguments for any SQL settings, or APP_URL. The container will copy an .env file to /config/www/.env on your host system for you to edit.
164159

165160

166161

@@ -205,6 +200,7 @@ Below are the instructions for updating containers:
205200

206201
## Versions
207202

203+
* **20.04.19:** - Rebase to Alpine 3.9, add MySQL init logic.
208204
* **22.03.19:** - Switching to new Base images, shift to arm32v7 tag.
209205
* **20.01.19:** - Added php7-curl
210206
* **04.11.18:** - Added php7-ldap

Diff for: docker-compose.advanced.yml.sample

-26
This file was deleted.

Diff for: docker-compose.basic.yml.sample

-30
This file was deleted.

Diff for: readme-vars.yml

+46-27
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
project_name: bookstack
55
project_url: "https://github.com/BookStackApp/BookStack"
66
project_logo: "https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/bookstack-logo500x500.png"
7+
project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}"
78
project_blurb: |
89
[{{ project_name|capitalize }}]({{ project_url }}) is a free and open source Wiki designed for creating beautiful documentation. Feautring a simple, but powerful WYSIWYG editor it allows for teams to create detailed and useful documentation with ease.
910
1011
Powered by SQL and including a Markdown editor for those who prefer it, BookStack is geared towards making documentation more of a pleasure than a chore.
1112
1213
For more information on BookStack visit their website and check it out: https://www.bookstackapp.com
13-
project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}"
1414
1515
# supported architectures
1616
available_architectures:
@@ -29,51 +29,70 @@ param_env_vars:
2929
- { env_var: "DB_USER", env_value: "<yourdbuser>", desc: "for specifying the database user" }
3030
- { env_var: "DB_PASS", env_value: "<yourdbpass>", desc: "for specifying the database password" }
3131
- { env_var: "DB_DATABASE", env_value: "bookstackapp", desc: "for specifying the database to be used" }
32-
- { env_var: "APP_URL", env_value: "your.site.here.xyz", desc: "for specifying the url your application will be accessed on (required for correct operation of reverse proxy)"}
3332

3433
param_usage_include_ports: true
3534
param_ports:
3635
- { external_port: "6875", internal_port: "80", port_desc: "will map the container's port 80 to port 6875 on the host" }
3736

37+
opt_param_usage_include_env: true
38+
opt_param_env_vars:
39+
- { env_var: "APP_URL", env_value: "your.site.here.xyz", desc: "for specifying the url your application will be accessed on (required for correct operation of reverse proxy)"}
40+
41+
custom_compose: |
42+
---
43+
version: "2"
44+
services:
45+
bookstack:
46+
image: linuxserver/bookstack
47+
container_name: bookstack
48+
environment:
49+
- PUID=1000
50+
- PGID=1000
51+
- DB_HOST=bookstack_db
52+
- DB_USER=bookstack
53+
- DB_PASS=<yourdbpass>
54+
- DB_DATABASE=bookstackapp
55+
volumes:
56+
- <path to data>:/config
57+
ports:
58+
- 6875:80
59+
restart: unless-stopped
60+
depends_on:
61+
- bookstack_db
62+
bookstack_db:
63+
image: linuxserver/mariadb
64+
container_name: bookstack_db
65+
environment:
66+
- PUID=1000
67+
- PGID=1000
68+
- MYSQL_ROOT_PASSWORD=<yourdbpass>
69+
- TZ=Europe/London
70+
- MYSQL_DATABASE=bookstackapp
71+
- MYSQL_USER=bookstack
72+
- MYSQL_PASSWORD=<yourdbpass>
73+
volumes:
74+
- <path to data>:/config
75+
restart: unless-stopped
76+
3877
# application setup block
3978
app_setup_block_enabled: true
4079
app_setup_block: |
41-
This application is dependent on an SQL database be it one you already have or a new one. If you do not already have one, set up our MariaDB container.
42-
43-
Once the MariaDB container is deployed, you can enter the following commands into the shell of the MariaDB container to create the user, password and database that the app will then use. Replace myuser/mypassword with your own data.
80+
Default username is [email protected] with password of **password**, access the container at http://dockerhost:6875.
4481
45-
**Note** this will allow any user with these credentials to connect to the server, it is not limited to localhost
82+
This application is dependent on an 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/.
4683
47-
```
48-
from shell on sql container:
49-
mysql -u root -p
50-
CREATE DATABASE bookstackapp;
51-
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword';
52-
GRANT ALL privileges ON `bookstackapp`.* TO 'myuser'@'%';
53-
FLUSH PRIVILEGES;
54-
```
55-
56-
Once you have completed these, you can then use the docker run command to create your BookStack container. Make sure you replace things such as <yourdbuser> with the correct data.
57-
58-
Then docker start bookstackapp to start the container. You should then be able to access the container at http://dockerhost:6875
59-
60-
Default username is [email protected] with password of **password**
61-
62-
If you intend to use this application behind a 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
84+
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
6385
6486
Documentation for BookStack can be found at https://www.bookstackapp.com/docs/
6587
6688
### Advanced Users (full control over the .env file)
6789
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.
6890
69-
When you create the container, do not set any arguments for any SQL settings, or APP_URL. The container will copy an .env file to /config/www/.env on your host system for you to edit.
70-
71-
### Composer
72-
73-
Some simple docker-compose files are included for you to get started with. You will still need to manually configure the SQL server, but the compose files will get the stack running for you.
91+
When you create the container, do not set any arguments for any SQL settings, or APP_URL. The container will copy an .env file to /config/www/.env on your host system for you to edit.
7492
7593
# changelog
7694
changelogs:
95+
- { date: "20.04.19:", desc: "Rebase to Alpine 3.9, add MySQL init logic." }
7796
- { date: "22.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." }
7897
- { date: "20.01.19:", desc: "Added php7-curl"}
7998
- { date: "04.11.18:", desc: "Added php7-ldap"}

Diff for: root/etc/cont-init.d/50-config

+23-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ elif [ -f "/config/BOOKSTACK_APP_KEY.txt" ];
3737
fi
3838

3939
# .env file setup
40+
# check for the default app key or if it has been updated
41+
if grep -Fxq "APP_KEY=SomeRandomString" /config/www/.env || \
42+
! grep -Fxq "APP_KEY=${key}" /config/www/.env; then
43+
sed -i "s#^APP_KEY=.*#APP_KEY=${key}#" /config/www/.env
44+
fi
4045
# check to see if db_user is set, if it is then run seds and if not then leave them
4146
if [ "${DB_USER}" ];
4247
then
4348
echo "Running config - db_user set"
44-
sed -i "s,APP_KEY=SomeRandomString,APP_KEY=${key},g" /config/www/.env
4549
sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /config/www/.env
4650
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env
4751
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env
@@ -51,10 +55,28 @@ fi
5155
# set appurl if detected
5256
[[ "${APP_URL}" ]] && sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /config/www/.env
5357

58+
# check for the mysql endpoint for 30 seconds
59+
END=$((SECONDS+30))
60+
while [ ${SECONDS} -lt ${END} ]; do
61+
/usr/bin/nc -z ${DB_HOST} 3306 && \
62+
if [ ! -z "$(/usr/bin/nc -w1 ${DB_HOST} 3306)" ]; then
63+
[ ! -z "${RUN}" ] && break
64+
RUN="RAN"
65+
# we sleep here again due to first run init on DB containers
66+
[ ! -f /dbwait.lock ] && sleep 5
67+
else
68+
sleep 1
69+
fi
70+
sleep 1
71+
done
72+
5473
# update database - will set up database if fresh, or, migrate existing
5574
php /var/www/html/artisan migrate --force
5675

5776
# set permissions
5877
chown -R abc:abc \
5978
/config \
6079
/var/www/
80+
81+
# set lockfile to avoid DB waits for this specific container
82+
touch /dbwait.lock

0 commit comments

Comments
 (0)