Skip to content

Modifications to make container release ready #9

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 18 commits into from
Oct 11, 2018
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: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lsiobase/alpine.nginx:3.7
FROM lsiobase/alpine.nginx:3.8

# set version label
ARG BUILD_DATE
Expand Down Expand Up @@ -41,7 +41,6 @@ RUN \
tar xf \
/tmp/bookstack.tar.gz -C \
/var/www/html/ --strip-components=1 && \
cp /var/www/html/.env.example /var/www/html/.env && \
echo "**** install composer ****" && \
cd /tmp && \
curl -sS https://getcomposer.org/installer | php && \
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lsiobase/alpine.nginx.arm64:3.7
FROM lsiobase/alpine.nginx.arm64:3.8

# Add qemu to build on x86_64 systems
COPY qemu-aarch64-static /usr/bin
Expand Down Expand Up @@ -44,7 +44,6 @@ RUN \
tar xf \
/tmp/bookstack.tar.gz -C \
/var/www/html/ --strip-components=1 && \
cp /var/www/html/.env.example /var/www/html/.env && \
echo "**** install composer ****" && \
cd /tmp && \
curl -sS https://getcomposer.org/installer | php && \
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lsiobase/alpine.nginx.armhf:3.7
FROM lsiobase/alpine.nginx.armhf:3.8

# Add qemu to build on x86_64 systems
COPY qemu-arm-static /usr/bin
Expand Down Expand Up @@ -44,7 +44,6 @@ RUN \
tar xf \
/tmp/bookstack.tar.gz -C \
/var/www/html/ --strip-components=1 && \
cp /var/www/html/.env.example /var/www/html/.env && \
echo "**** install composer ****" && \
cd /tmp && \
curl -sS https://getcomposer.org/installer | php && \
Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ pipeline {
sh "docker manifest push --purge ${IMAGE}:latest || :"
sh "docker manifest create ${IMAGE}:latest ${IMAGE}:amd64-latest ${IMAGE}:arm32v6-latest ${IMAGE}:arm64v8-latest"
sh "docker manifest annotate ${IMAGE}:latest ${IMAGE}:arm32v6-latest --os linux --arch arm"
sh "docker manifest annotate ${IMAGE}:latest ${IMAGE}:arm64v8-latest --os linux --arch arm64 --variant armv8"
sh "docker manifest annotate ${IMAGE}:latest ${IMAGE}:arm64v8-latest --os linux --arch arm64 --variant v8"
sh "docker manifest push --purge ${IMAGE}:${EXT_RELEASE}-ls${LS_TAG_NUMBER} || :"
sh "docker manifest create ${IMAGE}:${META_TAG} ${IMAGE}:amd64-${META_TAG} ${IMAGE}:arm32v6-${META_TAG} ${IMAGE}:arm64v8-${META_TAG}"
sh "docker manifest annotate ${IMAGE}:${META_TAG} ${IMAGE}:arm32v6-${META_TAG} --os linux --arch arm"
sh "docker manifest annotate ${IMAGE}:${META_TAG} ${IMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant armv8"
sh "docker manifest annotate ${IMAGE}:${META_TAG} ${IMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8"
sh "docker manifest push --purge ${IMAGE}:latest"
sh "docker manifest push --purge ${IMAGE}:${META_TAG}"
}
Expand Down Expand Up @@ -474,7 +474,7 @@ pipeline {
-e DOCKERHUB_USERNAME=$DOCKERUSER \
-e DOCKERHUB_PASSWORD=$DOCKERPASS \
-e GIT_REPOSITORY=${LS_USER}/${LS_REPO} \
-e DOCKER_REPOSITORY=${DOCKERHUB_IMAGE} \
-e DOCKER_REPOSITORY=${IMAGE} \
-e GIT_BRANCH=master \
lsiodev/readme-sync bash -c 'node sync' '''
}
Expand Down
26 changes: 26 additions & 0 deletions docker-compose.advanced.yml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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:
30 changes: 30 additions & 0 deletions docker-compose.basic.yml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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:
17 changes: 17 additions & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ 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: "APPURL", env_value: "your.site.here.xyz", desc: "for specifying the url your application will be accessed on "}
- { env_var: "ADVANCED_MODE", env_value: "1", desc: "enables advanced mode for direct editing of the .env - scroll down for details on this"}

param_usage_include_ports: true
param_ports:
Expand Down Expand Up @@ -57,8 +59,23 @@ app_setup_block: |

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 `APPURL` environment variable is set, or it will not work

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

### Advanced Mode
We have implemented a special 'advanced mode' where users who wish to leverage the built in SMTP or LDAP functionality, will have the ability to edit the .env by hand. With `ADVANCED_MODE=1` set when
the container is created, it will copy the .env.example to /config within the container. You can then edit this file on the host system (make sure you read the BookStack docs) and restart the
container when finished. When the container starts, it copies /config/.env to /var/www/html/.env within the container for the web app to use. It will do this every time the container restarts.

Note, the APP_KEY is still set by PHP environment so you do not need to worrry about this.

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

# changelog
changelogs:
- { date: "08.10.18:", desc: "Advanced mode, symlink changes, sed fixing, docs updated, added some composer files"}
- { date: "23.09.28:", desc: "Updates pre-release"}
- { date: "02.07.18:", desc: "Initial Release." }
51 changes: 36 additions & 15 deletions root/etc/cont-init.d/50-config
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
#!/usr/bin/with-contenv bash

# create our folders
# create directory structure
mkdir -p \
/config/storage \
/config/uploads
/config/www/{uploads,files,images}

# make symlinks
[[ ! -L /var/www/html/storage ]] && \
ln -sf /config/storage /var/www/html/storage
[[ ! -L /var/www/html/public/uploads ]] && \
ln -sf /config/uploads /var/www/html/public/uploads
# create symlinks
symlinks=( \
/var/www/html/storage/uploads/files \
/var/www/html/storage/uploads/images \
/var/www/html/public/uploads )

for i in "${symlinks[@]}"
do
[[ -e "$i" && ! -L "$i" ]] && rm -rf "$i"
[[ ! -L "$i" ]] && ln -s /config/www/"$(basename "$i")" "$i"
done

# Check for ADVANCED_MODE to be set. If set, copy sample env file to /config and then copy to /var/www/html.env so advanced users can make their own customisations
# If not set, runs in basic mode where .example.env is copied to /var/www/html/.env and seds are applied to set documented variables
if [ "$ADVANCED_MODE" == 1 ];
then
echo "Advanced Mode Enabled - Syncing .env from /config to /var/www/html - if you're doing this you better read the BookStack documentation. Restart container after making changes to .env"
[[ ! -f "/config/.env" ]] && \
cp /var/www/html/.env.example /config/.env
cp /config/.env /var/www/html/.env
elif [ -z "$ADVANCED_MODE" ];
then
echo "Basic Mode Enabled - Using sed to set BookStack variables from Docker environment variables - check the docs"
cp /var/www/html/.env.example /var/www/html/.env
# set up .env
sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /var/www/html/.env
sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env
sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env
else
echo "Nothing to do with .env - what did you do homer?"
fi

# Check to see if appurl is set, and whether advanced mode is set. Will set .env APP_URL if variable present, and advanced mode not set
if [ ! -z "$APP_URL" -a -z "$ADVANCED_MODE" ];
then
echo "App URL Set"
sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env
fi

# Create API key if needed
if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ]
then
Expand All @@ -26,13 +54,6 @@ if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ]
echo "App Key set to $key you can modify the file to update /config/BOOKSTACK_APP_KEY.txt"
fi

# set up .env
sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /var/www/html/.env
sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env
sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env

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

Expand Down