Skip to content

Commit 238309c

Browse files
committed
Merge pull request #1 from SolidNerd/refactoring
Refactor it to the latest docker standards and ADD docker-compose.yml
2 parents 09ca123 + 67108dc commit 238309c

File tree

4 files changed

+152
-23
lines changed

4 files changed

+152
-23
lines changed

Dockerfile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
FROM php:5.6-apache
22
MAINTAINER kilhog@protonmail.com
3-
RUN apt-get update && apt-get install -y git zlib1g-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev \
3+
4+
ENV BOOKSTACK BookStack
5+
ENV BOOKSTACK_VERSION 0.9.2
6+
7+
RUN apt-get update && apt-get install -y git zlib1g-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev wget \
48
&& docker-php-ext-install pdo pdo_mysql mbstring zip \
59
&& docker-php-ext-configure gd --with-freetype-dir=usr/include/ --with-jpeg-dir=/usr/include/ \
6-
&& docker-php-ext-install gd
7-
RUN cd ~ && curl -sS https://getcomposer.org/installer | php
8-
RUN mv ~/composer.phar /usr/local/bin/composer
9-
RUN cd /var/www/ && git clone https://github.com/ssddanbrown/BookStack.git --branch 0.7.2 --single-branch BookStack
10-
RUN cd /var/www/BookStack && composer install
11-
RUN chown -R www-data:www-data /var/www/BookStack
10+
&& docker-php-ext-install gd \
11+
&& cd /var/www && curl -sS https://getcomposer.org/installer | php \
12+
&& mv /var/www/composer.phar /usr/local/bin/composer \
13+
&& wget https://github.com/ssddanbrown/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz -O ${BOOKSTACK}.tar.gz \
14+
&& tar -xf ${BOOKSTACK}.tar.gz && mv BookStack-${BOOKSTACK_VERSION} ${BOOKSTACK} && rm ${BOOKSTACK}.tar.gz \
15+
&& cd /var/www/BookStack && composer install \
16+
&& chown -R www-data:www-data /var/www/BookStack \
17+
&& apt-get -y autoremove \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
20+
1221
COPY bookstack.conf /etc/apache2/sites-enabled/bookstack.conf
1322
RUN a2enmod rewrite
1423

1524
COPY docker-entrypoint.sh /
16-
ENTRYPOINT ["/docker-entrypoint.sh"]
25+
26+
EXPOSE 80
27+
28+
ENTRYPOINT ["/docker-entrypoint.sh"]

README.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
11
# Docker Image For [BookStack](https://github.com/ssddanbrown/BookStack)
22
[![](https://badge.imagelayers.io/kilhog/bookstack:latest.svg)](https://imagelayers.io/?images=kilhog/bookstack:latest 'Get your own badge on imagelayers.io')
3-
* 0.7.2 ([Dockerfile](https://github.com/Kilhog/docker-bookstack/blob/master/Dockerfile))
43

5-
## How to use this image
4+
## Current Version: [0.9.2 ](https://github.com/Kilhog/docker-bookstack/blob/master/Dockerfile)
65

7-
### Run MySQL Container
6+
## Quickstart
7+
With Docker Compose is a Quickstart very easy. Run the following command:
8+
9+
```
10+
docker-compose up
11+
```
12+
13+
and after that open your Browser and go to `http://localhost:8080` .
14+
15+
16+
## How to use the Image without Docker compose
17+
Networking changed in Docker v1.9, so you need to do one of the following steps.
18+
19+
### Docker < v1.9
20+
1. MySQL Container:
821
```
9-
docker pull mysql
1022
docker run -d --name bookstack-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=bookstack -e MYSQL_USER=bookstack -e MYSQL_PASSWORD=secret mysql
1123
```
12-
### Run Bookstack Container
24+
2. BookStack Container:
1325
```
14-
docker pull kilhog/bookstack
1526
docker run --name my-bookstack -d --link bookstack-mysql:mysql -p 8080:80 kilhog/bookstack
1627
```
1728

18-
Now you can access to BookStack with : ip-adress-of-docker-machine:8080 👍
29+
### Docker 1.9+
30+
1. Create a shared network:
31+
`docker network create bookstack_nw`
32+
33+
2. MySQL container :
34+
```
35+
docker run -d --net bookstack_nw \
36+
-e MYSQL_ROOT_PASSWORD=secret \
37+
-e MYSQL_DATABASE=bookstack \
38+
-e MYSQL_USER=bookstack \
39+
-e MYSQL_PASSWORD=secret \
40+
--name="bookstack_db" \
41+
mysql
42+
```
43+
44+
3. Create BookStack Container
45+
```
46+
docker run -d --net bookstack_nw \
47+
-e DB_HOST=bookstack_db \
48+
-e DB_DATABASE=bookstack \
49+
-e DB_USERNAME=bookstack \
50+
-e DB_PASSWORD=secret \
51+
-p 8080:80
52+
kilhog/bookstack
53+
```
54+
55+
After the steps you can visit `http://localhost:8080` .

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '2'
2+
services:
3+
bookstack:
4+
image: kilhog/bookstack
5+
depends_on:
6+
- db
7+
environment:
8+
- DB_HOST=db
9+
- DB_DATABASE=bookstack
10+
- DB_USERNAME=bookstack
11+
- DB_PASSWORD=secret
12+
ports:
13+
- "8080:80"
14+
db:
15+
image: mysql:5.7.12
16+
environment:
17+
- MYSQL_ROOT_PASSWORD=secret
18+
- MYSQL_DATABASE=bookstack
19+
- MYSQL_USER=bookstack
20+
- MYSQL_PASSWORD=secret

docker-entrypoint.sh

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,81 @@
11
#!/bin/bash
22
set -e
33

4+
echoerr() { echo "$@" 1>&2; }
5+
46
if [ ! -f '/var/www/BookStack/.env' ]; then
5-
cp /var/www/BookStack/.env.example /var/www/BookStack/.env
7+
if [ "$DB_HOST" ]; then
8+
cat > /var/www/BookStack/.env <<EOF
9+
# Environment
10+
APP_ENV=production
11+
APP_DEBUG=false
12+
APP_KEY=SomeRandomString
13+
14+
# Database details
15+
DB_HOST=${DB_HOST:-localhost}
16+
DB_DATABASE=${DB_DATABASE:-bookstack}
17+
DB_USERNAME=${DB_USERNAME:-bookstack}
18+
DB_PASSWORD=${DB_PASSWORD:-password}
19+
20+
# Cache and session
21+
CACHE_DRIVER=file
22+
SESSION_DRIVER=file
23+
# If using Memcached, comment the above and uncomment these
24+
#CACHE_DRIVER=memcached
25+
#SESSION_DRIVER=memcached
26+
QUEUE_DRIVER=sync
27+
28+
# Memcached settings
29+
# If using a UNIX socket path for the host, set the port to 0
30+
# This follows the following format: HOST:PORT:WEIGHT
31+
# For multiple servers separate with a comma
32+
MEMCACHED_SERVERS=127.0.0.1:11211:100
33+
34+
# Storage
35+
STORAGE_TYPE=local
36+
# Amazon S3 Config
37+
STORAGE_S3_KEY=false
38+
STORAGE_S3_SECRET=false
39+
STORAGE_S3_REGION=false
40+
STORAGE_S3_BUCKET=false
41+
# Storage URL
42+
# Used to prefix image urls for when using custom domains/cdns
43+
STORAGE_URL=false
644
7-
if [ "$MYSQL_PORT_3306_TCP" ]; then
8-
sed -i "s/\(DB_HOST *= *\).*/\1mysql/" '/var/www/BookStack/.env'
9-
sed -i "s/\(DB_DATABASE *= *\).*/\1${MYSQL_ENV_MYSQL_DATABASE:-root}/" '/var/www/BookStack/.env'
10-
sed -i "s/\(DB_USERNAME *= *\).*/\1${MYSQL_ENV_MYSQL_USER:-$MYSQL_ENV_MYSQL_ROOT_PASSWORD}/" '/var/www/BookStack/.env'
11-
sed -i "s/\(DB_PASSWORD *= *\).*/\1${MYSQL_ENV_MYSQL_PASSWORD:-bookstack}/" '/var/www/BookStack/.env'
45+
# General auth
46+
AUTH_METHOD=standard
1247
13-
cd /var/www/BookStack/ && php artisan key:generate && php artisan migrate --force
48+
# Social Authentication information. Defaults as off.
49+
GITHUB_APP_ID=false
50+
GITHUB_APP_SECRET=false
51+
GOOGLE_APP_ID=false
52+
GOOGLE_APP_SECRET=false
53+
# URL used for social login redirects, NO TRAILING SLASH
54+
EOF
1455
else
1556
echo >&2 'warning: missing MYSQL_PORT_3306_TCP environment variables'
1657
echo >&2 ' Did you forget to --link some_mysql_container:mysql ?'
1758
exit 1
1859
fi
1960
fi
2061

21-
apache2-foreground
62+
echoerr wait-for-db: waiting for ${DB_HOST}:3306
63+
64+
timeout 15 bash <<EOT
65+
while ! (echo > /dev/tcp/${DB_HOST}/3306) >/dev/null 2>&1;
66+
do sleep 1;
67+
done;
68+
EOT
69+
RESULT=$?
70+
71+
if [ $RESULT -eq 0 ]; then
72+
# sleep another second for so that we don't get a "the database system is starting up" error
73+
sleep 1
74+
echoerr wait-for-db: done
75+
else
76+
echoerr wait-for-db: timeout out after 15 seconds waiting for ${DB_HOST}:3306
77+
fi
78+
79+
cd /var/www/BookStack/ && php artisan key:generate && php artisan migrate --force
80+
81+
exec apache2-foreground

0 commit comments

Comments
 (0)