From a86c8498dc8ebc59546660701a54b839bf417516 Mon Sep 17 00:00:00 2001 From: DoTheEvo Date: Fri, 31 Dec 2021 01:35:58 +0100 Subject: [PATCH] update --- docker-basics-and-troubleshoot/readme.md | 98 ++++++++++ jellyfin/readme.md | 223 +++++++++++++++++++++++ nextcloud/readme.md | 2 +- phpipam/readme.md | 5 +- 4 files changed, 324 insertions(+), 4 deletions(-) create mode 100644 docker-basics-and-troubleshoot/readme.md create mode 100644 jellyfin/readme.md diff --git a/docker-basics-and-troubleshoot/readme.md b/docker-basics-and-troubleshoot/readme.md new file mode 100644 index 0000000..35cf08a --- /dev/null +++ b/docker-basics-and-troubleshoot/readme.md @@ -0,0 +1,98 @@ +# Docker basics and troubleshooting + +###### guide-by-example + +![logo](https://i.imgur.com/GrWPooR.png) + + +# Purpose + +For me to wrap head around some shit. +Notes for troubleshooting. + +What was at one time tested and should 100% work. + +# docker-compose + +`docker-compose.yml` +```yml +services: + + whoami: + image: "containous/whoami" + container_name: "whoami" + hostname: "whoami" + ports: + - "80:80" +``` + + + +# Scheduling and cron issues + +The default docker-compose deployment uses cron container.
+Problem is it does not work, so Ofelia is used.
+[Here](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/ofelia) +is guide how to set it up. + +Bellow is Ofelia's config file for discovery and ping check of live hosts. + +`config.ini` +```ini +[job-exec "phpipam ping"] +schedule = @every 10m +container = phpipam-web +command = /usr/bin/php /phpipam/functions/scripts/pingCheck.php + +[job-exec "phpipam discovery"] +schedule = @every 25m +container = phpipam-web +command = /usr/bin/php /phpipam/functions/scripts/discoveryCheck.php +``` + +# Reverse proxy + +Caddy v2 is used, details +[here](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2).
+ +`Caddyfile` +``` +ipam.{$MY_DOMAIN} { + reverse_proxy phpipam-web:80 +} +``` + +# First run + +![logo](https://i.imgur.com/W7YhwqK.jpg) + + +* New phpipam installation +* Automatic database installation +* MySQL username: root +* MySQL password: my_secret_mysql_root_pass + +# Update + +[Watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower) +updates the image automatically. + +Manual image update: + +- `docker-compose pull`
+- `docker-compose up -d`
+- `docker image prune` + +# Backup and restore + +#### Backup + +Using [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup) +that makes daily snapshot of the entire directory. + +#### Restore + +* down the homer container `docker-compose down`
+* delete the entire homer directory
+* from the backup copy back the homer directory
+* start the container `docker-compose up -d` diff --git a/jellyfin/readme.md b/jellyfin/readme.md new file mode 100644 index 0000000..7533010 --- /dev/null +++ b/jellyfin/readme.md @@ -0,0 +1,223 @@ +# Bookstack in docker + +###### guide-by-example + +![logo](https://i.imgur.com/qDXwqaU.png) + +# Purpose & Overview + +Documentation and notes. + +* [Official site](https://www.bookstackapp.com/) +* [Github](https://github.com/BookStackApp/BookStack) +* [DockerHub](https://hub.docker.com/r/linuxserver/bookstack) + +BookStack is a modern, open source, good looking wiki platform +for storing and organizing information and documentation. + +Written in PHP, with MySQL database for the user data.
+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 + +``` +/home/ +└── ~/ + └── docker/ + └── bookstack/ + ├── bookstack-data/ + ├── bookstack-db-data/ + ├── .env + ├── docker-compose.yml + └── bookstack-backup-script.sh +``` + +* `bookstack-data/` - a directory where bookstack will store its web app data +* `bookstack-db-data/` - a directory where bookstack will store its MySQL database data +* `.env` - a file containing environment variables for docker compose +* `docker-compose.yml` - a docker compose file, telling docker how to run the containers +* `bookstack-backup-script.sh` - a backup script if you want it + +You only need to provide the files.
+The directories are created by docker compose on the first run. + +# docker-compose + +Dockerhub linuxserver/bookstack +[example compose.](https://hub.docker.com/r/linuxserver/bookstack) + +`docker-compose.yml` +```yml +version: "2" +services: + + bookstack-db: + image: linuxserver/mariadb + container_name: bookstack-db + hostname: bookstack-db + restart: unless-stopped + env_file: .env + volumes: + - ./bookstack-db-data:/config + + bookstack: + image: linuxserver/bookstack + container_name: bookstack + hostname: bookstack + restart: unless-stopped + env_file: .env + depends_on: + - bookstack-db + volumes: + - ./bookstack-data:/config + +networks: + default: + external: + name: $DOCKER_MY_NETWORK +``` + +`.env` +```bash +# GENERAL +MY_DOMAIN=example.com +DOCKER_MY_NETWORK=caddy_net +TZ=Europe/Bratislava + +#LINUXSERVER.IO +PUID=1000 +PGID=1000 + +# BOOKSTACK-MARIADB +MYSQL_ROOT_PASSWORD=bookstack +MYSQL_DATABASE=bookstack +MYSQL_USER=bookstack +MYSQL_PASSWORD=bookstack + +# BOOKSTACK +APP_URL=https://book.example.com +DB_HOST=bookstack-db +DB_USER=bookstack +DB_PASS=bookstack +DB_DATABASE=bookstack + +# USING SENDGRID FOR SENDING EMAILS +MAIL_ENCRYPTION=SSL +MAIL_DRIVER=smtp +MAIL_HOST=smtp.sendgrid.net +MAIL_PORT=465 +MAIL_FROM=book@example.com +MAIL_USERNAME=apikey +SMTP_PASSWORD= +``` + +**All containers must be on the same network**.
+Which is named in the `.env` file.
+If one does not exist yet: `docker network create caddy_net` + +# Reverse proxy + +Caddy v2 is used, details +[here](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2).
+ +`Caddyfile` +``` +book.{$MY_DOMAIN} { + reverse_proxy bookstack:80 +} +``` + +# First run + +Default login: `admin@admin.com` // `password` + +--- + +![interface-pic](https://i.imgur.com/cN1GUZw.png) + +# Update + +[Watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower) +updates the image automatically. + +Manual image update: + +- `docker-compose pull`
+- `docker-compose up -d`
+- `docker image prune` + +# Backup and restore + +#### Backup + +Using [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup) +that makes daily snapshot of the entire directory. + +#### Restore + +* down the bookstack containers `docker-compose down`
+* delete the entire bookstack directory
+* from the backup copy back the bookstack directory
+* 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/)
+For bookstack it means database dump and backing up several directories +containing user uploaded files. + +Daily [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup) run +takes care of backing up the directories. +So only database dump is needed.
+The created backup sqlite3 file is overwritten on every run of the script, +but that's ok since borg is making daily snapshots. + +#### Create a 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 + +Running on the host, so that the script will be periodically run. + +* `su` - switch to root +* `crontab -e` - add new cron job
+* `0 22 * * * /home/bastard/docker/bookstack/bookstack-backup-script.sh`
+ 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, first restore the database before running the app container. + +* 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
+ `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/`
+ replace directories `files`,`images`,`uploads` and the file `.env`
+ 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`
+ `docker container exec -it bookstack /bin/bash`
+ `cd /var/www/html/`
+ `php artisan migrate` + +Again, the above steps are based on the +[official procedure.](https://www.bookstackapp.com/docs/admin/backup-restore/) diff --git a/nextcloud/readme.md b/nextcloud/readme.md index 47eb55d..6c0e079 100644 --- a/nextcloud/readme.md +++ b/nextcloud/readme.md @@ -75,7 +75,7 @@ services: image: mariadb container_name: nextcloud-db hostname: nextcloud-db - command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW + command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb_read_only_compressed=OFF restart: unless-stopped env_file: .env volumes: diff --git a/phpipam/readme.md b/phpipam/readme.md index dd6b70f..036116c 100644 --- a/phpipam/readme.md +++ b/phpipam/readme.md @@ -19,8 +19,7 @@ IP address managment, LAN information and documentation tool. IPAM is a universal term that stands for [IP Address Management](https://en.wikipedia.org/wiki/IP_address_management).
- -phpIPAM is open source tool fullfilling this purpose. +phpIPAM is an open source tool fullfilling this purpose. Coded in php and using mariadb for database. My exposure to it is limited and at this moment @@ -84,7 +83,7 @@ services: ```bash # GENERAL DOCKER_MY_NETWORK=caddy_net -TZ=EuropeBratislava +TZ=Europe/Bratislava IPAM_DATABASE_HOST=phpipam-mariadb IPAM_DATABASE_PASS=my_secret_phpipam_pass