Skip to content

Commit dcb3229

Browse files
authored
Merge pull request #10 from linuxserver/memcached
Added memcached, simplified use for manipulating the .env file, moved some bits around
2 parents 1ba731b + 3ff047b commit dcb3229

File tree

9 files changed

+45
-40
lines changed

9 files changed

+45
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ $RECYCLE.BIN/
4141
Network Trash Folder
4242
Temporary Items
4343
.apdisk
44+
docker-compose.yml

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ RUN \
1313
echo "**** install build packages ****" && \
1414
apk add --no-cache \
1515
curl \
16+
memcached \
1617
php7-ctype \
1718
php7-dom \
1819
php7-gd \
1920
php7-mbstring \
21+
php7-memcached \
2022
php7-mysqlnd \
2123
php7-openssl \
2224
php7-pdo_mysql \

Dockerfile.aarch64

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ RUN \
1616
echo "**** install build packages ****" && \
1717
apk add --no-cache \
1818
curl \
19+
memcached \
1920
php7-ctype \
2021
php7-dom \
2122
php7-gd \
2223
php7-mbstring \
24+
php7-memcached \
2325
php7-mysqlnd \
2426
php7-openssl \
2527
php7-pdo_mysql \

Dockerfile.armhf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ RUN \
1616
echo "**** install build packages ****" && \
1717
apk add --no-cache \
1818
curl \
19+
memcached \
1920
php7-ctype \
2021
php7-dom \
2122
php7-gd \
2223
php7-mbstring \
24+
php7-memcached \
2325
php7-mysqlnd \
2426
php7-openssl \
2527
php7-pdo_mysql \

Jenkinsfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ pipeline {
1717
BUILDS_DISCORD = credentials('build_webhook_url')
1818
GITHUB_TOKEN = credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab')
1919
DIST_IMAGE = 'alpine'
20-
DIST_TAG = '3.7'
20+
DIST_TAG = '3.8'
2121
DIST_PACKAGES = 'curl \
22+
memcached \
2223
php7-openssl \
2324
php7-pdo_mysql \
2425
php7-mbstring \
26+
php7-memcached \
2527
php7-tidy \
2628
php7-phar \
2729
php7-dom \

readme-vars.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ param_env_vars:
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" }
3232
- { env_var: "APPURL", env_value: "your.site.here.xyz", desc: "for specifying the url your application will be accessed on "}
33-
- { env_var: "ADVANCED_MODE", env_value: "1", desc: "enables advanced mode for direct editing of the .env - scroll down for details on this"}
3433

3534
param_usage_include_ports: true
3635
param_ports:
@@ -63,19 +62,18 @@ app_setup_block: |
6362
6463
Documentation can be found at https://www.bookstackapp.com/docs/
6564
66-
### Advanced Mode
67-
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
68-
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
69-
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.
70-
71-
Note, the APP_KEY is still set by PHP environment so you do not need to worrry about this.
65+
### Advanced Users
66+
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.
67+
68+
When you create the container, do not set any arguements for SQL or APPURL. The container will copy an .env file to /config/www/.env on your host system for you to edit.
7269
7370
### Composer
7471
7572
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.
7673
7774
# changelog
7875
changelogs:
76+
- { date: "15.10.18:", desc: "Changed functionality for advanced users"}
7977
- { date: "08.10.18:", desc: "Advanced mode, symlink changes, sed fixing, docs updated, added some composer files"}
8078
- { date: "23.09.28:", desc: "Updates pre-release"}
8179
- { date: "02.07.18:", desc: "Initial Release." }

root/etc/cont-init.d/50-config

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,53 @@
44
mkdir -p \
55
/config/www/{uploads,files,images}
66

7+
# check for .env and copy default if needed
8+
[[ ! -f "/config/www/.env" ]] && \
9+
cp /var/www/html/.env.example /config/www/.env
10+
711
# create symlinks
812
symlinks=( \
913
/var/www/html/storage/uploads/files \
1014
/var/www/html/storage/uploads/images \
11-
/var/www/html/public/uploads )
15+
/var/www/html/public/uploads \
16+
/var/www/html/.env \
17+
/var/www/html/storage/logs/laravel.log
18+
)
1219

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

19-
# 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
20-
# 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
21-
if [ "$ADVANCED_MODE" == 1 ];
22-
then
23-
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"
24-
[[ ! -f "/config/.env" ]] && \
25-
cp /var/www/html/.env.example /config/.env
26-
cp /config/.env /var/www/html/.env
27-
elif [ -z "$ADVANCED_MODE" ];
28-
then
29-
echo "Basic Mode Enabled - Using sed to set BookStack variables from Docker environment variables - check the docs"
30-
cp /var/www/html/.env.example /var/www/html/.env
31-
# set up .env
32-
sed -i "s/APP_KEY=SomeRandomString/APP_KEY=$key/g" /var/www/html/.env
33-
sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /var/www/html/.env
34-
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /var/www/html/.env
35-
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /var/www/html/.env
36-
sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /var/www/html/.env
37-
else
38-
echo "Nothing to do with .env - what did you do homer?"
39-
fi
40-
41-
# 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
42-
if [ ! -z "$APP_URL" -a -z "$ADVANCED_MODE" ];
43-
then
44-
echo "App URL Set"
45-
sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /var/www/html/.env
46-
fi
47-
4826
# Create API key if needed
49-
if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ]
27+
if [ ! -f "/config/BOOKSTACK_APP_KEY.txt" ];
5028
then
5129
echo "Generating BookStack app key for first run"
5230
key=$(php /var/www/html/artisan key:generate --show | tr -d '//' )
5331
echo $key > /config/BOOKSTACK_APP_KEY.txt
5432
echo "App Key set to $key you can modify the file to update /config/BOOKSTACK_APP_KEY.txt"
33+
elif [ -f "/config/BOOKSTACK_APP_KEY.txt" ];
34+
then
35+
echo "App Key found - setting variable for seds"
36+
key=$(cat /config/BOOKSTACK_APP_KEY.txt)
37+
fi
38+
39+
# .env file setup
40+
# check to see if db_user is set, if it is then run seds and if not then leave them
41+
if [ "${DB_USER}" ];
42+
then
43+
echo "Running config - db_user set"
44+
sed -i "s,APP_KEY=SomeRandomString,APP_KEY=${key},g" /config/www/.env
45+
sed -i "s/DB_HOST=localhost/DB_HOST=${DB_HOST}/g" /config/www/.env
46+
sed -i "s/DB_DATABASE=database_database/DB_DATABASE=${DB_DATABASE}/g" /config/www/.env
47+
sed -i "s/DB_USERNAME=database_username/DB_USERNAME=${DB_USER}/g" /config/www/.env
48+
sed -i "s/DB_PASSWORD=database_user_password/DB_PASSWORD=${DB_PASS}/g" /config/www/.env
5549
fi
5650

51+
# set appurl if detected
52+
[[ "${APP_URL}" ]] && sed -i "s,#\sAPP_URL.*,APP_URL=${APP_URL},g" /config/www/.env
53+
5754
# update database - will set up database if fresh, or, migrate existing
5855
php /var/www/html/artisan migrate --force
5956

root/etc/services.d/memcached/run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/with-contenv bash
2+
exec memcached -u abc

root/etc/services.d/php-fpm/run

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/usr/bin/with-contenv bash
2-
export APP_KEY=$(cat /config/BOOKSTACK_APP_KEY.txt)
32
exec /usr/sbin/php-fpm7 -F

0 commit comments

Comments
 (0)