Skip to content

Rebase to Alpine 3.9, add MySQL init logic, fix app key bug #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lsiobase/nginx:3.8
FROM lsiobase/nginx:3.9

# set version label
ARG BUILD_DATE
Expand All @@ -15,6 +15,7 @@ RUN \
curl \
tar \
memcached \
netcat-openbsd \
php7-ctype \
php7-curl \
php7-dom \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lsiobase/nginx:arm64v8-3.8
FROM lsiobase/nginx:arm64v8-3.9

# set version label
ARG BUILD_DATE
Expand All @@ -15,6 +15,7 @@ RUN \
curl \
tar \
memcached \
netcat-openbsd \
php7-ctype \
php7-curl \
php7-dom \
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lsiobase/nginx:arm32v7-3.8
FROM lsiobase/nginx:arm32v7-3.9

# set version label
ARG BUILD_DATE
Expand All @@ -15,6 +15,7 @@ RUN \
curl \
tar \
memcached \
netcat-openbsd \
php7-ctype \
php7-curl \
php7-dom \
Expand Down
54 changes: 25 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ docker create \
-e DB_USER=<yourdbuser> \
-e DB_PASS=<yourdbpass> \
-e DB_DATABASE=bookstackapp \
-e APP_URL=your.site.here.xyz \
-e APP_URL=your.site.here.xyz `#optional` \
-p 6875:80 \
-v <path to data>:/config \
--restart unless-stopped \
Expand All @@ -83,16 +83,32 @@ services:
environment:
- PUID=1000
- PGID=1000
- DB_HOST=<yourdbhost>
- DB_USER=<yourdbuser>
- DB_HOST=bookstack_db
- DB_USER=bookstack
- DB_PASS=<yourdbpass>
- DB_DATABASE=bookstackapp
- APP_URL=your.site.here.xyz
volumes:
- <path to data>:/config
ports:
- 6875:80
restart: unless-stopped
depends_on:
- bookstack_db
bookstack_db:
image: linuxserver/mariadb
container_name: bookstack_db
environment:
- PUID=1000
- PGID=1000
- MYSQL_ROOT_PASSWORD=<yourdbpass>
- TZ=Europe/London
- MYSQL_DATABASE=bookstackapp
- MYSQL_USER=bookstack
- MYSQL_PASSWORD=<yourdbpass>
volumes:
- <path to data>:/config
restart: unless-stopped

```

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

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.

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.
Default username is admin@admin.com with password of **password**, access the container at http://dockerhost:6875.

**Note** this will allow any user with these credentials to connect to the server, it is not limited to localhost
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/.

```
from shell on sql container:
mysql -u root -p
CREATE DATABASE bookstackapp;
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword';
GRANT ALL privileges ON `bookstackapp`.* TO 'myuser'@'%';
FLUSH PRIVILEGES;
```

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.

Then docker start bookstackapp to start the container. You should then be able to access the container at http://dockerhost:6875

Default username is admin@admin.com with password of **password**

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
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

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

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

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.

### Composer

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.
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.



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

## Versions

* **20.04.19:** - Rebase to Alpine 3.9, add MySQL init logic.
* **22.03.19:** - Switching to new Base images, shift to arm32v7 tag.
* **20.01.19:** - Added php7-curl
* **04.11.18:** - Added php7-ldap
Expand Down
26 changes: 0 additions & 26 deletions docker-compose.advanced.yml.sample

This file was deleted.

30 changes: 0 additions & 30 deletions docker-compose.basic.yml.sample

This file was deleted.

73 changes: 46 additions & 27 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
project_name: bookstack
project_url: "https://github.com/BookStackApp/BookStack"
project_logo: "https://s3-us-west-2.amazonaws.com/linuxserver-docs/images/bookstack-logo500x500.png"
project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}"
project_blurb: |
[{{ 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.

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.

For more information on BookStack visit their website and check it out: https://www.bookstackapp.com
project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}"

# supported architectures
available_architectures:
Expand All @@ -29,51 +29,70 @@ param_env_vars:
- { env_var: "DB_USER", env_value: "<yourdbuser>", desc: "for specifying the database user" }
- { env_var: "DB_PASS", env_value: "<yourdbpass>", desc: "for specifying the database password" }
- { env_var: "DB_DATABASE", env_value: "bookstackapp", desc: "for specifying the database to be used" }
- { 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)"}

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

opt_param_usage_include_env: true
opt_param_env_vars:
- { 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)"}

custom_compose: |
---
version: "2"
services:
bookstack:
image: linuxserver/bookstack
container_name: bookstack
environment:
- PUID=1000
- PGID=1000
- DB_HOST=bookstack_db
- DB_USER=bookstack
- DB_PASS=<yourdbpass>
- DB_DATABASE=bookstackapp
volumes:
- <path to data>:/config
ports:
- 6875:80
restart: unless-stopped
depends_on:
- bookstack_db
bookstack_db:
image: linuxserver/mariadb
container_name: bookstack_db
environment:
- PUID=1000
- PGID=1000
- MYSQL_ROOT_PASSWORD=<yourdbpass>
- TZ=Europe/London
- MYSQL_DATABASE=bookstackapp
- MYSQL_USER=bookstack
- MYSQL_PASSWORD=<yourdbpass>
volumes:
- <path to data>:/config
restart: unless-stopped

# application setup block
app_setup_block_enabled: true
app_setup_block: |
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.

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.
Default username is admin@admin.com with password of **password**, access the container at http://dockerhost:6875.

**Note** this will allow any user with these credentials to connect to the server, it is not limited to localhost
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/.

```
from shell on sql container:
mysql -u root -p
CREATE DATABASE bookstackapp;
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword';
GRANT ALL privileges ON `bookstackapp`.* TO 'myuser'@'%';
FLUSH PRIVILEGES;
```

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.

Then docker start bookstackapp to start the container. You should then be able to access the container at http://dockerhost:6875

Default username is admin@admin.com with password of **password**

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
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

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

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

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.

### Composer

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.
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.

# changelog
changelogs:
- { date: "20.04.19:", desc: "Rebase to Alpine 3.9, add MySQL init logic." }
- { date: "22.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." }
- { date: "20.01.19:", desc: "Added php7-curl"}
- { date: "04.11.18:", desc: "Added php7-ldap"}
Expand Down
24 changes: 23 additions & 1 deletion root/etc/cont-init.d/50-config
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ elif [ -f "/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
fi
# check to see if db_user is set, if it is then run seds and if not then leave them
if [ "${DB_USER}" ];
then
echo "Running config - db_user set"
sed -i "s,APP_KEY=SomeRandomString,APP_KEY=${key},g" /config/www/.env
sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /config/www/.env
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env
Expand All @@ -51,10 +55,28 @@ fi
# set appurl if detected
[[ "${APP_URL}" ]] && sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /config/www/.env

# check for the mysql endpoint for 30 seconds
END=$((SECONDS+30))
while [ ${SECONDS} -lt ${END} ]; 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
done

# update database - will set up database if fresh, or, migrate existing
php /var/www/html/artisan migrate --force

# set permissions
chown -R abc:abc \
/config \
/var/www/

# set lockfile to avoid DB waits for this specific container
touch /dbwait.lock