Skip to content

Commit 6c8b1bd

Browse files
authored
Shift examples from file RUN.md to directory .examples (#134)
1 parent cf57a0d commit 6c8b1bd

10 files changed

Lines changed: 354 additions & 315 deletions

File tree

.dockerignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
# Ignore GitHub actions
66
.github
77

8-
# Ignore all the markdown files
8+
# Ignore documentation and examples
99
*.md
10+
.examples
1011

1112
# Ignore secrets files
12-
db_root_pwd.txt
13-
db_user_pwd.txt
13+
pwd*.txt
1414

1515
# Ignore LICENSE file
1616
LICENSE

.examples/insecure/READ.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Testing Librebooking as a container
2+
3+
This setup is meant for accessing the application from your local network.
4+
It features:
5+
6+
* A librebooking container reachable at <http://localhost>
7+
* A docker volume
8+
* A cron container
9+
10+
## Using the command line
11+
12+
Start the application
13+
```sh
14+
bash start.sh
15+
```
16+
17+
Stop the application
18+
```sh
19+
bash stop.sh
20+
```
21+
22+
Delete the application containers
23+
```sh
24+
docker container rm librebooking-db librebooking-app
25+
```
26+
27+
Delete the application docker volumes
28+
```sh
29+
docker volume rm librebooking-db librebooking-conf
30+
```
31+
## Using docker-compose.yml
32+
33+
Customize the environment variables inside files `db.env` and `lb.env`
34+
35+
Start the application
36+
```sh
37+
docker compose up --detach
38+
```
39+
40+
Stop the application and delete the containers
41+
```sh
42+
docker compose down
43+
```
44+
45+
Remove the application docker volumes
46+
```sh
47+
docker compose down --volumes
48+
```

.examples/insecure/db.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MYSQL_ROOT_PASSWORD=db_root_pwd
2+
TZ=Europe/Zurich
3+
PUID=1000
4+
PGID=1000
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: librebooking
2+
3+
services:
4+
db:
5+
image: linuxserver/mariadb:10.6.13
6+
restart: always
7+
volumes:
8+
- db_conf:/config
9+
env_file:
10+
- db.env
11+
app:
12+
image: librebooking/librebooking:develop
13+
restart: always
14+
depends_on:
15+
- db
16+
ports:
17+
- "80:80"
18+
volumes:
19+
- app_conf:/config
20+
env_file:
21+
- lb.env
22+
cron:
23+
image: librebooking/librebooking:develop
24+
restart: always
25+
user: root
26+
entrypoint: /usr/local/bin/cron.sh
27+
depends_on:
28+
- app
29+
volumes:
30+
- app_conf:/config
31+
env_file:
32+
- lb.env
33+
34+
volumes:
35+
db_conf:
36+
app_conf:

.examples/insecure/lb.env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
LB_DATABASE_NAME=librebooking
2+
LB_DATABASE_USER=lb_user
3+
LB_DATABASE_PASSWORD=db_user_pwd
4+
LB_DATABASE_HOSTSPEC=db
5+
LB_INSTALL_PASSWORD=app_install_pwd
6+
LB_LOGGING_FOLDER=/var/log/librebooking
7+
LB_LOGGING_LEVEL=DEBUG
8+
LB_LOGGING_SQL=false
9+
LB_DEFAULT_TIMEZONE=Europe/Zurich

.examples/insecure/start.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/bash
2+
3+
set -eux
4+
5+
# Create the docker network
6+
docker network create mynet
7+
8+
# Start the database container
9+
docker run \
10+
--detach \
11+
--name librebooking-db \
12+
--network mynet \
13+
--volume librebooking-db:/config \
14+
--env PUID=1000 \
15+
--env PGID=1000 \
16+
--env TZ=Europe/Zurich \
17+
--env MYSQL_ROOT_PASSWORD=db_root_pwd \
18+
linuxserver/mariadb:10.6.13
19+
20+
# Start the librabooking app container
21+
docker run \
22+
--detach \
23+
--name librebooking-app \
24+
--network mynet \
25+
--publish 80:80 \
26+
--volume librebooking-conf:/config \
27+
--env LB_DATABASE_NAME=librebooking \
28+
--env LB_DATABASE_USER=lb_user \
29+
--env LB_DATABASE_PASSWORD=db_user_pwd \
30+
--env LB_DATABASE_HOSTSPEC=librebooking-db \
31+
--env LB_INSTALL_PASSWORD=app_install_pwd \
32+
--env LB_LOGGING_FOLDER=/var/log/librebooking \
33+
--env LB_LOGGING_LEVEL=DEBUG \
34+
--env LB_LOGGING_SQL=false \
35+
--env LB_DEFAULT_TIMEZONE=Europe/Zurich \
36+
librebooking/librebooking:develop
37+
38+
# Start the Librebooking cron container
39+
docker run \
40+
--detach \
41+
--name librebooking-cron \
42+
--user root \
43+
--entrypoint /usr/local/bin/cron.sh \
44+
--network mynet \
45+
--volume librebooking-conf:/config \
46+
--env LB_DATABASE_NAME=librebooking \
47+
--env LB_DATABASE_USER=lb_user \
48+
--env LB_DATABASE_PASSWORD=db_user_pwd \
49+
--env LB_DATABASE_HOSTSPEC=librebooking-db \
50+
--env LB_LOGGING_FOLDER=/var/log/librebooking \
51+
--env LB_LOGGING_LEVEL=DEBUG \
52+
--env LB_LOGGING_SQL=false \
53+
--env LB_DEFAULT_TIMEZONE=Europe/Zurich \
54+
librebooking/librebooking:develop

.examples/insecure/stop.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/bash
2+
3+
set -eux
4+
5+
# Stop the Librebooking cron container
6+
docker stop librebooking-cron
7+
8+
# Start the librabooking app container
9+
docker stop librebooking-app
10+
11+
# Start the database container
12+
docker stop librebooking-db
13+
14+
# Delete the docker network
15+
docker network create mynet

.examples/secure/READ.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Running Librebooking container in production
2+
3+
This setup is meant for accessing the application from the internet.
4+
It features:
5+
6+
* A reverse proxy based on nginx that automatically handle certificates
7+
* The usage of secrets to forward passwords to the docker container
8+
* A librebooking service `lb1` reachable at <https://your.host.com/book>
9+
* A librebooking service `lb2` reachable at <https://your.host.com>
10+
* 2 docker volumes for services `lb1` and `lb2`
11+
* 2 cron jobs for services `lb1` and `lb2`
12+
13+
## Setup
14+
15+
Set the secrets with the following commands:
16+
17+
```sh
18+
echo -n 'db_root_pwd' > pwd_db_root.txt;
19+
echo -n 'db_user_pwd' > pwd_db_user.txt;
20+
echo -n 'app_install_pwd' > pwd_lb_inst.txt;
21+
```
22+
23+
## Container management
24+
25+
Start the application
26+
```sh
27+
docker compose up --detach
28+
```
29+
30+
Stop the application and delete the containers
31+
```sh
32+
docker compose down
33+
```
34+
35+
Remove the application docker volumes
36+
```sh
37+
docker compose down --volumes
38+
```
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: librebooking
2+
3+
services:
4+
proxy:
5+
image: nginxproxy/nginx-proxy
6+
restart: always
7+
networks:
8+
- mynet
9+
ports:
10+
- 80:80
11+
- 443:443
12+
volumes:
13+
- proxy_certs:/etc/nginx/certs
14+
- proxy_html:/usr/share/nginx/html
15+
- /var/run/docker.sock:/tmp/docker.sock:ro
16+
acme:
17+
image: nginxproxy/acme-companion
18+
restart: always
19+
depends_on:
20+
- proxy
21+
volumes_from:
22+
- proxy
23+
volumes:
24+
- acme_acme:/etc/acme.sh
25+
- /var/run/docker.sock:/var/run/docker.sock:ro
26+
environment:
27+
- DEFAULT_EMAIL=john.doe@acme.org
28+
db:
29+
image: linuxserver/mariadb:10.6.13
30+
restart: always
31+
volumes:
32+
- db_conf:/config
33+
environment:
34+
- PUID=1000
35+
- PGID=1000
36+
- TZ=Europe/Zurich
37+
- FILE__MYSQL_ROOT_PASSWORD=/run/secrets/db_root_pwd
38+
secrets:
39+
- db_root_pwd
40+
- db_user_pwd
41+
lb1:
42+
image: librebooking/librebooking:4.0.0
43+
restart: always
44+
depends_on:
45+
- db
46+
volumes:
47+
- lb1_conf:/config
48+
environment:
49+
- APP_PATH=book
50+
- LB_DATABASE_NAME=lb1
51+
- LB_INSTALL_PASSWORD_FILE=/run/secrets/lb_install_pwd
52+
- LB_DATABASE_USER=lb1
53+
- LB_DATABASE_PASSWORD_FILE=/run/secrets/lb_user_pwd
54+
- LB_DATABASE_HOSTSPEC=db
55+
- LB_LOGGING_FOLDER=/var/log/librebooking
56+
- LB_LOGGING_LEVEL=ERROR
57+
- LB_LOGGING_SQL=false
58+
- LB_DEFAULT_TIMEZONE=Europe/Zurich
59+
- VIRTUAL_HOST=acme.org
60+
- VIRTUAL_PATH=/book
61+
- LETSENCRYPT_HOST=acme.org
62+
secrets:
63+
- lb_install_pwd
64+
- lb_user_pwd
65+
job1:
66+
image: librebooking/librebooking:4.0.0
67+
restart: always
68+
depends_on:
69+
- lb1
70+
user: root
71+
entrypoint: /usr/local/bin/cron.sh
72+
volumes:
73+
- lb1_conf:/config
74+
environment:
75+
- LB_DATABASE_NAME=lb1
76+
- LB_DATABASE_USER=lb1
77+
- LB_DATABASE_PASSWORD_FILE=/run/secrets/lb_user_pwd
78+
- LB_DATABASE_HOSTSPEC=db
79+
- LB_LOGGING_FOLDER=/var/log/librebooking
80+
- LB_LOGGING_LEVEL=ERROR
81+
- LB_LOGGING_SQL=false
82+
- LB_DEFAULT_TIMEZONE=Europe/Zurich
83+
secrets:
84+
- lb_user_pwd
85+
lb2:
86+
image: librebooking/librebooking:4.0.0
87+
restart: always
88+
depends_on:
89+
- db
90+
volumes:
91+
- lb2_conf:/config
92+
- ./uploads/images:/var/www/html/Web/uploads/images
93+
- ./uploads/reservation:/var/www/html/Web/uploads/reservation
94+
environment:
95+
- LB_DATABASE_NAME=lb2
96+
- LB_INSTALL_PASSWORD_FILE=/run/secrets/lb_install_pwd
97+
- LB_DATABASE_USER=lb2
98+
- LB_DATABASE_PASSWORD_FILE=/run/secrets/lb_user_pwd
99+
- LB_DATABASE_HOSTSPEC=db
100+
- LB_LOGGING_FOLDER=/var/log/librebooking
101+
- LB_LOGGING_LEVEL=ERROR
102+
- LB_LOGGING_SQL=false
103+
- LB_DEFAULT_TIMEZONE=Europe/Zurich
104+
- VIRTUAL_HOST=acme.org
105+
- LETSENCRYPT_HOST=acme.org
106+
secrets:
107+
- lb_install_pwd
108+
- lb_user_pwd
109+
job2:
110+
image: librebooking/librebooking:4.0.0
111+
restart: always
112+
depends_on:
113+
- lb2
114+
user: root
115+
entrypoint: /usr/local/bin/cron.sh
116+
volumes:
117+
- lb2_conf:/config
118+
environment:
119+
- LB_DATABASE_NAME=lb2
120+
- LB_DATABASE_USER=lb2
121+
- LB_DATABASE_PASSWORD_FILE=/run/secrets/lb_user_pwd
122+
- LB_DATABASE_HOSTSPEC=db
123+
- LB_LOGGING_FOLDER=/var/log/librebooking
124+
- LB_LOGGING_LEVEL=ERROR
125+
- LB_LOGGING_SQL=false
126+
- LB_DEFAULT_TIMEZONE=Europe/Zurich
127+
secrets:
128+
- lb_user_pwd
129+
130+
volumes:
131+
proxy_certs:
132+
proxy_html:
133+
acme_acme:
134+
db_conf:
135+
lb1_conf:
136+
lb2_conf:
137+
138+
secrets:
139+
db_root_pwd:
140+
file: ./pwd_db_root.txt
141+
db_user_pwd:
142+
file: ./pwd_db_user.txt
143+
lb_user_pwd:
144+
file: ./pwd_db_user.txt
145+
lb_install_pwd:
146+
file: ./pwd_lb_inst.txt

0 commit comments

Comments
 (0)