diff --git a/Dockerfile b/Dockerfile index 728d2e9..d95f3a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lsiobase/nginx:3.8 +FROM lsiobase/nginx:3.9 # set version label ARG BUILD_DATE @@ -15,6 +15,7 @@ RUN \ curl \ tar \ memcached \ + netcat-openbsd \ php7-ctype \ php7-curl \ php7-dom \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index f1c6de6..50cb8fe 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM lsiobase/nginx:arm64v8-3.8 +FROM lsiobase/nginx:arm64v8-3.9 # set version label ARG BUILD_DATE @@ -15,6 +15,7 @@ RUN \ curl \ tar \ memcached \ + netcat-openbsd \ php7-ctype \ php7-curl \ php7-dom \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 15b5faa..1f8c864 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,4 +1,4 @@ -FROM lsiobase/nginx:arm32v7-3.8 +FROM lsiobase/nginx:arm32v7-3.9 # set version label ARG BUILD_DATE @@ -15,6 +15,7 @@ RUN \ curl \ tar \ memcached \ + netcat-openbsd \ php7-ctype \ php7-curl \ php7-dom \ diff --git a/README.md b/README.md index 3726f3e..563402f 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ docker create \ -e DB_USER= \ -e DB_PASS= \ -e DB_DATABASE=bookstackapp \ - -e APP_URL=your.site.here.xyz \ + -e APP_URL=your.site.here.xyz `#optional` \ -p 6875:80 \ -v :/config \ --restart unless-stopped \ @@ -83,16 +83,32 @@ services: environment: - PUID=1000 - PGID=1000 - - DB_HOST= - - DB_USER= + - DB_HOST=bookstack_db + - DB_USER=bookstack - DB_PASS= - DB_DATABASE=bookstackapp - - APP_URL=your.site.here.xyz volumes: - :/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= + - TZ=Europe/London + - MYSQL_DATABASE=bookstackapp + - MYSQL_USER=bookstack + - MYSQL_PASSWORD= + volumes: + - :/config + restart: unless-stopped + ``` ## Parameters @@ -128,39 +144,18 @@ In this instance `PUID=1000` and `PGID=1000`, to find yours use `id user` as bel   ## 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 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. @@ -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 diff --git a/docker-compose.advanced.yml.sample b/docker-compose.advanced.yml.sample deleted file mode 100644 index 73231e5..0000000 --- a/docker-compose.advanced.yml.sample +++ /dev/null @@ -1,26 +0,0 @@ -version: '3' -services: - sql: - container_name: bookstack_sql - image: linuxserver/mariadb - volumes: - - ./data/sql:/config - networks: - - net - environment: - - PUID=setyourID - - PGID=setyourGID - - MYSQL_ROOT_PASSWORD=SetAPassword - bookstack: - container_name: bookstack - image: linuxserver/bookstack - volumes: - - ./data/bookstack:/config - environment: - - ADVANCED_MODE=1 - - PUID=setyourID - - PGID=setyourGID - networks: - - net -networks: - net: diff --git a/docker-compose.basic.yml.sample b/docker-compose.basic.yml.sample deleted file mode 100644 index 6e3061f..0000000 --- a/docker-compose.basic.yml.sample +++ /dev/null @@ -1,30 +0,0 @@ -version: '3' -services: - sql: - container_name: bookstack_sql - image: linuxserver/mariadb - volumes: - - ./data/sql:/config - networks: - - net - environment: - - PUID=setyourID - - PGID=setyourGID - - MYSQL_ROOT_PASSWORD=SetAPassword - bookstack: - container_name: bookstack - image: linuxserver/bookstack - volumes: - - ./data/bookstack:/config - environment: - - DB_USER=bookstack - - DB_PASS=SetAPassword - - DB_DATABASE=bookstack - - DB_HOST=bookstack_sql - - "APP_URL=https://your.url.when.using.reverse.proxy" - - PUID=setyourID - - PGID=setyourGID - networks: - - net -networks: - net: diff --git a/readme-vars.yml b/readme-vars.yml index 0a4bebf..6c7bd7e 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -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: @@ -29,51 +29,70 @@ param_env_vars: - { env_var: "DB_USER", env_value: "", desc: "for specifying the database user" } - { env_var: "DB_PASS", env_value: "", 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= + - DB_DATABASE=bookstackapp + volumes: + - :/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= + - TZ=Europe/London + - MYSQL_DATABASE=bookstackapp + - MYSQL_USER=bookstack + - MYSQL_PASSWORD= + volumes: + - :/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 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"} diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index b5085c0..2862925 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -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 @@ -51,6 +55,21 @@ 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 @@ -58,3 +77,6 @@ php /var/www/html/artisan migrate --force chown -R abc:abc \ /config \ /var/www/ + +# set lockfile to avoid DB waits for this specific container +touch /dbwait.lock