This commit is contained in:
DoTheEvo 2023-03-13 00:46:50 +01:00
parent 202ccb4bb8
commit 504ba3ddce
1 changed files with 25 additions and 121 deletions

View File

@ -1,24 +1,20 @@
a# Mealie in docker # Mealie in docker
###### guide-by-example ###### guide-by-example
![logo](https://i.imgur.com/qDXwqaU.png) ![logo](https://i.imgur.com/G546d6v.png)
# Purpose & Overview # Purpose & Overview
Documentation and notes. Recipe cookbook.
* [Official site](https://www.bookstackapp.com/) * [The official site](https://hay-kot.github.io/mealie/)
* [Github](https://github.com/BookStackApp/BookStack) * [Github](https://github.com/hay-kot/mealie)
* [DockerHub](https://hub.docker.com/r/linuxserver/bookstack) * [DockerHub](https://hub.docker.com/r/hkotel/mealie)
BookStack is a modern, open source, good looking wiki platform Mealie is a simple, open source, self hosted cookbook.<br>
for storing and organizing information. Written in python and javascript, using Vue framework for frontend.
It stores recipies in plain json as well as sqlite database.
Written in PHP, using Laravel framework, with MySQL database for the user data.</br>
There is no official Dockerhub image so the one maintained by
[linuxserver.io](https://www.linuxserver.io/) is used,
which uses nginx as a web server.
# Files and directory structure # Files and directory structure
@ -27,25 +23,21 @@ which uses nginx as a web server.
└── ~/ └── ~/
└── docker/ └── docker/
└── bookstack/ └── bookstack/
├── 🗁 bookstack_data/ ├── 🗁 mealie_data/
├── 🗁 bookstack_db_data/
├── 🗋 .env ├── 🗋 .env
├── 🗋 docker-compose.yml └── 🗋 docker-compose.yml
└── 🗋 bookstack-backup-script.sh
``` ```
* `bookstack_data/` - a directory with bookstacks web app data * `mealie_data/` - a directory with persistent data and backups
* `bookstack_db_data/` - a directory with database data
* `.env` - a file containing environment variables for docker compose * `.env` - a file containing environment variables for docker compose
* `docker-compose.yml` - a docker compose file, telling docker how to run the containers * `docker-compose.yml` - a docker compose file, telling docker how to run the containers
* `bookstack-backup-script.sh` - a backup script, to be run daily
Only the files are required. The directories are created on the first run. Only the files are required. The directory is created on the first run.
# docker-compose # docker-compose
Dockerhub linuxserver/bookstack The official documentation compose example
[example compose.](https://hub.docker.com/r/linuxserver/bookstack) [here.](https://hay-kot.github.io/mealie/documentation/getting-started/install/#docker-compose-with-sqlite)
`docker-compose.yml` `docker-compose.yml`
```yml ```yml
@ -57,10 +49,10 @@ services:
hostname: mealie hostname: mealie
restart: unless-stopped restart: unless-stopped
env_file: .env env_file: .env
volumes:
- ./mealie_data:/app/data
expose: expose:
- 80:80 - "80"
volumes:
- ./mealie_data/:/app/data
networks: networks:
default: default:
@ -74,7 +66,6 @@ networks:
DOCKER_MY_NETWORK=caddy_net DOCKER_MY_NETWORK=caddy_net
TZ=Europe/Bratislava TZ=Europe/Bratislava
# MEALIE # MEALIE
PUID=1000 PUID=1000
PGID=1000 PGID=1000
@ -84,24 +75,12 @@ RECIPE_SHOW_ASSETS=true
RECIPE_LANDSCAPE_VIEW=true RECIPE_LANDSCAPE_VIEW=true
RECIPE_DISABLE_COMMENTS=false RECIPE_DISABLE_COMMENTS=false
RECIPE_DISABLE_AMOUNT=false RECIPE_DISABLE_AMOUNT=false
# USING SENDINBLUE FOR SENDING EMAILS
MAIL_DRIVER=smtp
MAIL_ENCRYPTION=tls
MAIL_HOST=smtp-relay.sendinblue.com
MAIL_PORT=587
MAIL_FROM=book@example.com
MAIL_USERNAME=<registration-email@gmail.com>
MAIL_PASSWORD=<sendinblue-smtp-key-goes-here>
``` ```
**All containers must be on the same network**.</br> **All containers must be on the same network**.</br>
Which is named in the `.env` file.</br> Which is named in the `.env` file.</br>
If one does not exist yet: `docker network create caddy_net` If one does not exist yet: `docker network create caddy_net`
`APP_URL` in the `.env` **must be set** for bookstack to work.<br>
`MAIL_` stuff must be set for password reset and new registrations.
# Reverse proxy # Reverse proxy
Caddy v2 is used, details Caddy v2 is used, details
@ -110,30 +89,23 @@ Caddy v2 is used, details
`Caddyfile` `Caddyfile`
```php ```php
book.{$MY_DOMAIN} { book.{$MY_DOMAIN} {
reverse_proxy bookstack:80 reverse_proxy mealie:80
} }
``` ```
# First run # First run
Default login: `admin@admin.com` // `password` Default login: `changeme@email.com` // `MyPassword`
--- ---
![interface-pic](https://i.imgur.com/cN1GUZw.png) ![interface-pic](https://i.imgur.com/Y1VtD0e.png)
# Trouble shooting # New version incomig
* It did not start.<br> There is a new version in work, v1.0.0 is already in beta5,
Ctrl+f in `.env` file for word `example` to be replaced with actual domain but it seems a major changes are introduced and theres not yet feature to
name. `APP_URL` has to be set correctly for bookstack to work. share recipies with people without password.
* After update cant see edit tools.<br>
Clear browsers cookies/cache.
* The test email button in preferences throws error.<br>
Exec in to the container and `printenv` to see.
Check [mail.php](https://github.com/BookStackApp/BookStack/blob/development/app/Config/mail.php)
to see exact `MAIL_` env variables names and default values.
Test in Thunderbird your smtp server working or not.
# Update # Update
@ -146,12 +118,6 @@ Manual image update:
It is **strongly recommended** to now add current **tags** to the images in the compose.<br> It is **strongly recommended** to now add current **tags** to the images in the compose.<br>
Tags will allow you to easily return to a working state if an update goes wrong. Tags will allow you to easily return to a working state if an update goes wrong.
If there was a **major version jump**, and bookstack does not work,
exec in to the app container and run php artisan migrate</br>
`docker container exec -it bookstack /bin/bash`</br>
`cd /app/www`</br>
`php artisan migrate`
# Backup and restore # Backup and restore
#### Backup #### Backup
@ -166,65 +132,3 @@ to make daily snapshot of the entire docker directory.
* delete/move/rename the entire project directory</br> * delete/move/rename the entire project directory</br>
* from the backups copy back the entire project directory</br> * from the backups copy back the entire project directory</br>
* start the containers `docker-compose up -d` * start the containers `docker-compose up -d`
# Backup of just user data
Users data daily export using the
[official procedure.](https://www.bookstackapp.com/docs/admin/backup-restore/)</br>
For bookstack it means database dump and backing up several directories
containing user uploaded files.
Daily kopia/borg backup run takes care of backing up the directories.
So only database dump is needed and done with the script.</br>
The created backup sql file is overwritten on every run of the script,
but that's ok since kopia/borg are keeping daily snapshots.
#### Backup script
Placed inside `bookstack` directory on the host
`bookstack-backup-script.sh`
```bash
#!/bin/bash
# CREATE DATABASE DUMP, bash -c '...' IS USED OTHERWISE OUTPUT > WOULD TRY TO GO TO THE HOST
docker container exec bookstack-db bash -c 'mysqldump -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE > $MYSQL_DIR/BACKUP.bookstack.database.sql'
```
The script must be **executable** - `chmod +x bookstack-backup-script.sh`
#### Cronjob - scheduled backup
Running on the host
* `su` - switch to root
* `crontab -e` - add new cron job</br>
* `0 22 * * * /home/bastard/docker/bookstack/bookstack-backup-script.sh`</br>
runs it every day [at 22:00](https://crontab.guru/#0_22_*_*_*)
* `crontab -l` - list cronjobs to check
# Restore the user data
Assuming clean start and latest images.<br>
Will need `BACKUP.bookstack.database.sql` and content of `bookstack_data/www/`<br>
Note that database restore must happen before bookstack app is first run.
* start only the database container: `docker-compose up -d bookstack-db`
* copy `BACKUP.bookstack.database.sql` in `bookstack/bookstack_db_data/`
* restore the database inside the container</br>
`docker container exec --workdir /config bookstack-db bash -c 'mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < BACKUP.bookstack.database.sql'`
* now start the app container: `docker-compose up -d`
* let it run so it creates its file structure
* down the containers `docker-compose down`
* in `bookstack/bookstack_data/www/`</br>
replace directories `files`,`images`,`uploads` and the file `.env`</br>
with the ones from the BorgBackup repository
* start the containers: `docker-compose up -d`
* if there was a major version jump, exec in to the app container and run `php artisan migrate`</br>
`docker container exec -it bookstack /bin/bash`</br>
`cd /app/www`</br>
`php artisan migrate`
Again, the above steps are based on the
[official procedure](https://www.bookstackapp.com/docs/admin/backup-restore/)
at the time of writing this.