Skip to content

Commit 772e21d

Browse files
author
Ian Walls
committed
Merge branch 'issue354'
2 parents 51c2e00 + e6981b7 commit 772e21d

File tree

1 file changed

+81
-24
lines changed

1 file changed

+81
-24
lines changed

docker/docker-compose.yml

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,91 @@
1+
#############################################
2+
# Instructions:
3+
#
4+
# create a .env file in the same directory as this file with the following content:
5+
#
6+
# LIBKI_ADMIN_USERNAME=your_admin_username
7+
# LIBKI_ADMIN_PASSWORD=your_admin_password
8+
# LIBKI_INSTANCE=your instance name (defaults to '')
9+
# LIBKI_TZ=timezone (defaults to 'America/New_York')
10+
# LIBKI_PORT=port on your localhost (defaults to 3000)
11+
# LIBKI_MAX_WORKERS=number of workers (defaults to 4)
12+
# DB_NAME=your_db_name (defaults to 'libki')
13+
# DB_USER=your_db_user (defaults to 'libki')
14+
# DB_PASS=your_db_pass
15+
# DB_ROOT_PASS=your_db_root_pass
16+
#
17+
# then run the following command:
18+
#
19+
# docker compose up -d
20+
# (you can remove '-d' to debug output interactively)
21+
#############################################
122
version: "3.9"
2-
23+
324
services:
4-
db:
5-
image: mariadb:10.3.5
6-
volumes:
7-
- db_data:/var/lib/mysql
25+
libki:
826
restart: always
27+
develop:
28+
watch:
29+
- action: sync+restart
30+
path: ../
31+
target: /app
32+
extra_hosts:
33+
- "host.docker.internal:host-gateway"
34+
build:
35+
context: ../
36+
dockerfile: docker/Dockerfile
37+
# dockerfile_inline: |
38+
# FROM libki/libki-server:latest
39+
40+
# set up cronjobs; see https://manual.libki.org/master/libki-manual.html#_cronjobs
41+
# RUN install_packages cron
42+
# RUN (crontab -l ; echo "* * * * * /app/script/cronjobs/libki.pl") | crontab -
43+
# RUN (crontab -l ; echo "0 0 * * * /app/script/cronjobs/libki_nightly.pl") | crontab -
44+
# RUN update-rc.d cron defaults
45+
46+
# EXPOSE 3000
47+
48+
# capture env, initialize db, ensure admin user credentials are up-to-date, then start the server
49+
# environment variables passed in from Docker get persisted at the top of the crontab file so all cron jobs have access to them
50+
# CMD (set | grep LIBKI ; crontab -l) | crontab - \
51+
# && ./installer/update_db.pl \
52+
# && /app/script/administration/create_user.pl -u ${LIBKI_ADMIN_USERNAME} -p ${LIBKI_ADMIN_PASSWORD} -s \
53+
# && service cron start \
54+
# && plackup -s Gazelle --port 3000 --max-reqs-per-child 50000 --max-workers ${LIBKI_MAX_WORKERS:-4} -E production -a /app/libki.psgi
55+
environment: # see https://manual.libki.org/master/libki-manual.html#_docker
56+
- LIBKI_INSTANCE=${LIBKI_INSTANCE:-libki}
57+
- LIBKI_DB_DSN=dbi:mysql:${DB_NAME:-libki};host=db;port=3306
58+
- LIBKI_DB_USER=${DB_USER:-libki}
59+
- LIBKI_DB_PASSWORD=${DB_PASS}
60+
- LIBKI_DB_HOST=db
61+
- LIBKI_DB_PORT=3306
62+
- LIBKI_DB_DATABASE=${DB_NAME:-libki}
63+
- LIBKI_TZ=${LIBKI_TZ:-America/New_York}
964
ports:
10-
- "127.0.0.1:3306:3306"
11-
environment:
12-
MYSQL_ROOT_PASSWORD: password
13-
MYSQL_DATABASE: libki
14-
MYSQL_USER: libki
15-
MYSQL_PASSWORD: libki
16-
17-
libki:
65+
- "${LIBKI_PORT:-3000}:3000"
1866
depends_on:
19-
- db
20-
image: libki/libki-server:latest
21-
ports:
22-
- "3000:3000"
67+
db:
68+
condition: service_healthy
69+
70+
db:
71+
image: mariadb:lts
2372
restart: always
2473
environment:
25-
LIBKI_DB_DSN=dbi:mysql:libki;host=db;port=3306
26-
LIBKI_DB_USER=root
27-
LIBKI_DB_PASSWORD=password
28-
LIBKI_DB_HOST=db
29-
LIBKI_DB_PORT=3306
30-
LIBKI_DB_DATABASE=libki
31-
TZ=America/New_York
74+
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASS}
75+
- MYSQL_DATABASE=${DB_NAME:-libki}
76+
- MYSQL_USER=${DB_USER:-libki}
77+
- MYSQL_PASSWORD=${DB_PASS}
78+
- TZ=${LIBKI_TZ:-America/New_York}
79+
volumes:
80+
- db_data:/var/lib/mysql
81+
ports:
82+
- "3306:3306" # you can remove this if you don't need to access MySQL directly from the host; the libki container will still be able to access it
83+
healthcheck: # wait for MariaDB to be ready before starting Libki
84+
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
85+
interval: 30s
86+
timeout: 10s
87+
retries: 5
88+
start_period: 30s # Give the database time to initialize
3289

3390
volumes:
3491
db_data: {}

0 commit comments

Comments
 (0)