Skip to content
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
60 changes: 31 additions & 29 deletions .examples/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Run librebooking with docker

## Using the command line (test)
## Using the command line

This setup is meant for accessing the application for testing purposes.
It features:
This example features:

* A librebooking container reachable at <http://localhost:8080>
* A persistent storage for the database and librebooking configuration files
* A cron container executing scheduled librebooking-related jobs
* A database container hosting the librebooking data
* Persistent volumes storage for the database, librebooking configuration,
uploaded images and reservations

Adapt files `db.env`and `lb.env` to your needs

Expand All @@ -23,7 +25,7 @@ docker container run \
--name librebooking-db \
--detach \
--network librebooking \
--hostname db
--hostname db \
--volume librebooking-db_conf:/config \
--env-file db.env \
docker.io/linuxserver/mariadb:10.6.13
Expand All @@ -34,18 +36,26 @@ docker run \
--network librebooking \
--publish 8080:8080 \
--volume librebooking-app_conf:/config \
--volume librebooking-app_img:/var/www/html/Web/uploads/images \
--volume librebooking-app_res:/var/www/html/Web/uploads/reservation \
--env-file lb.env \
docker.io/librebooking/librebooking:4.1.0
docker.io/librebooking/librebooking:develop

docker run \
--name librebooking-cron \
--detach \
--network librebooking \
--volumes-from librebooking-app\
--volume ./crontab:/config/lb-jobs-cron:ro \
--env-file lb.env \
docker.io/librebooking/librebooking:develop \
supercronic /config/lb-jobs-cron
```

## Using docker compose (test)
## Using docker compose

This setup is meant for accessing the application for testing purposes.
It features:

* A librebooking container reachable at <http://localhost:8080>
* A persistent storage for the database and librebooking configuration files
* A librebooking container used to run cron jobs
This setup is equivalent to the previous one, except it uses the
docker compose command.

Adapt files `db.env`and `lb.env` to your needs

Expand All @@ -55,26 +65,18 @@ Start the application
docker compose --file docker-compose-local.yml up --detach
```

## Using docker compose (production)
## Using docker compose with a reverse-proxy

This setup is meant for accessing the application for production purposes.
It features:
This example features:

* A reverse proxy based on nginx that automatically handle certificates
* A librebooking service `lb1` reachable at <https://your.host.com/book>
* A librebooking service `lb2` reachable at <https://your.host.com>
* 2 librebooking services `job1` and `job2` to handle cron jobs
* The usage of secrets to forward passwords to both containers

Adapt files `db.env`, `lb1.env` and `lb2.env` to your needs

Set the secret files
* A librebooking container reachable at <https://acme.org>
* A cron container executing scheduled librebooking-related jobs
* A database container hosting the librebooking data

```sh
echo -n 'db_root_pwd' > pwd_db_root.txt;
echo -n 'db_user_pwd' > pwd_db_user.txt;
echo -n 'app_install_pwd' > pwd_lb_inst.txt;
```
Adapt files `db.env`, `lb.env` to your needs
Adapt file `proxy.env` to your needs, if you are using the nginx proxy
Adapt file `docker-compose-public.yml` to your needs.

Start the application

Expand Down
7 changes: 6 additions & 1 deletion .examples/docker/docker-compose-local.yml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not try this, but the config volume removal caught my eye. Does cron really work without config being there?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I should have opened the full file, it gets it from app

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ services:
- "8080:8080"
volumes:
- app_conf:/config
- app_img:/var/www/html/Web/uploads/images
- app_res:/var/www/html/Web/uploads/reservation
env_file:
- lb.env
cron:
Expand All @@ -25,12 +27,15 @@ services:
command: supercronic /config/lb-jobs-cron
depends_on:
- app
volumes_from:
- app
volumes:
- app_conf:/config
- ./crontab:/config/lb-jobs-cron:ro
env_file:
- lb.env

volumes:
db_conf:
app_conf:
app_img:
app_res:
74 changes: 14 additions & 60 deletions .examples/docker/docker-compose-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,84 +32,38 @@ services:
- FILE__MYSQL_ROOT_PASSWORD=/run/secrets/db_root_pwd
env_file:
- db.env
secrets:
- db_root_pwd
- db_user_pwd
lb1:
app:
image: librebooking/librebooking:develop
restart: always
depends_on:
- db
volumes:
- lb1_conf:/config
- app_conf:/config
- app_img:/var/www/html/Web/uploads/images
- app_res:/var/www/html/Web/uploads/reservation
- ./crontab:/config/lb-jobs-cron:ro
env_file:
- lb1.env
- lb.env
environment:
- APP_PATH=book
- VIRTUAL_HOST=acme.org
- VIRTUAL_PORT=8080
- VIRTUAL_PATH=/book
- LETSENCRYPT_HOST=acme.org
secrets:
- lb_install_pwd
- lb_user_pwd
job1:
cron:
image: librebooking/librebooking:develop
restart: always
depends_on:
- lb1
- app
command: supercronic /config/lb-jobs-cron
volumes:
- lb1_conf:/config
env_file:
- lb1.env
secrets:
- lb_user_pwd
lb2:
image: librebooking/librebooking:develop
restart: always
depends_on:
- db
volumes:
- lb2_conf:/config
- ./uploads/images:/var/www/html/Web/uploads/images
- ./uploads/reservation:/var/www/html/Web/uploads/reservation
env_file:
- lb2.env
environment:
- VIRTUAL_HOST=acme.org
- VIRTUAL_PORT=8080
- LETSENCRYPT_HOST=acme.org
secrets:
- lb_install_pwd
- lb_user_pwd
job2:
image: librebooking/librebooking:develop
restart: always
depends_on:
- lb2
command: supercronic /config/lb-jobs-cron
volumes:
- lb2_conf:/config
volumes_from:
- app
env_file:
- lb2.env
secrets:
- lb_user_pwd
- lb.env

volumes:
proxy_certs:
proxy_html:
acme_acme:
db_conf:
lb1_conf:
lb2_conf:

secrets:
db_root_pwd:
file: ./pwd_db_root.txt
db_user_pwd:
file: ./pwd_db_user.txt
lb_user_pwd:
file: ./pwd_db_user.txt
lb_install_pwd:
file: ./pwd_lb_inst.txt
app_conf:
app_img:
app_res:
4 changes: 4 additions & 0 deletions .examples/docker/proxy.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DEFAULT_EMAIL=john.doe@acme.org
LETSENCRYPT_HOST=acme.org
VIRTUAL_HOST=acme.org
VIRTUAL_PORT=8080