Skip to content

Commit 38999a6

Browse files
authored
Merge pull request #387 from Paraphraser/20210809-nextcloud-mariadb-master
20210809 MariaDB + Nextcloud - master branch - PR 1 of 3
2 parents 56d9169 + b2e496e commit 38999a6

File tree

5 files changed

+106
-8
lines changed

5 files changed

+106
-8
lines changed

.templates/mariadb/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Download base image
2+
FROM ghcr.io/linuxserver/mariadb
3+
4+
# apply stability patches recommended in
5+
#
6+
# https://discord.com/channels/638610460567928832/638610461109256194/825049573520965703
7+
# https://stackoverflow.com/questions/61809270/how-to-discover-why-mariadb-crashes
8+
RUN sed -i.bak \
9+
-e "s/^thread_cache_size/# thread_cache_size/" \
10+
-e "s/^read_buffer_size/# read_buffer_size/" \
11+
/defaults/my.cnf
12+
13+
# EOF

.templates/mariadb/service.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mariadb:
2-
image: linuxserver/mariadb
2+
build: ./.templates/mariadb/.
33
container_name: mariadb
44
environment:
55
- TZ=Etc/UTC
@@ -11,6 +11,7 @@ mariadb:
1111
- MYSQL_PASSWORD=%randomPassword%
1212
volumes:
1313
- ./volumes/mariadb/config:/config
14+
- ./volumes/mariadb/db_backup:/backup
1415
ports:
1516
- "3306:3306"
1617
restart: unless-stopped

.templates/nextcloud/service.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ nextcloud:
1919

2020
nextcloud_db:
2121
container_name: nextcloud_db
22-
image: ghcr.io/linuxserver/mariadb
22+
build: ./.templates/mariadb/.
2323
restart: unless-stopped
2424
environment:
2525
- TZ=Etc/UTC
@@ -29,7 +29,10 @@ nextcloud_db:
2929
- MYSQL_PASSWORD=%randomMySqlPassword%
3030
- MYSQL_DATABASE=nextcloud
3131
- MYSQL_USER=nextcloud
32+
ports:
33+
- "9322:3306"
3234
volumes:
3335
- ./volumes/nextcloud/db:/config
36+
- ./volumes/nextcloud/db_backup:/backup
3437
networks:
3538
- nextcloud_internal

docs/Containers/MariaDB.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,75 @@
44

55
## About
66

7-
MariaDB is a fork of MySQL. This is an unofficial image provided by linuxserver.io because there is no official image for arm
7+
MariaDB is a fork of MySQL. This is an unofficial image provided by linuxserver.io because there is no official image for arm.
88

9-
## Conneting to the DB
9+
## Connecting to the DB
1010

1111
The port is 3306. It exists inside the docker network so you can connect via `mariadb:3306` for internal connections. For external connections use `<your Pis IP>:3306`
1212

1313
![image](https://user-images.githubusercontent.com/46672225/69734358-7f030800-1137-11ea-9874-7d2c86b3d239.png)
1414

1515
## Setup
1616

17-
Before starting the stack edit the `./services/mariadb/mariadb.env` file and set your access details. This is optional however you will only have one shot at the preconfig. If you start the container without setting the passwords then you will have to either delete its volume directory or enter the terminal and change manually
17+
Before starting the stack, edit the `docker-compose.yml` file and check your environment variables. In particular:
1818

19-
The env file has three commented fields for credentials, either **all three** must be commented or un-commented. You can't have only one or two, its all or nothing.
19+
```
20+
environment:
21+
- TZ=Etc/UTC
22+
- MYSQL_ROOT_PASSWORD=
23+
- MYSQL_DATABASE=default
24+
- MYSQL_USER=mariadbuser
25+
- MYSQL_PASSWORD=
26+
```
27+
28+
If you are running old-menu, you will have to set both passwords. Under new-menu, the menu may have allocated random passwords for you but you can change them if you like.
29+
30+
You only get the opportunity to change the `MQSL_` prefixed environment variables before you bring up the container for the first time. If you decide to change these values after initialisation, you will either have to:
31+
32+
1. Erase the persistent storage area and start again. There are three steps:
33+
34+
* Stop the container and remove the persistent storage area:
35+
36+
```
37+
$ cd ~/IOTstack
38+
$ docker-compose rm --force --stop -v mariadb
39+
$ sudo rm -rf ./volumes/mariadb
40+
```
41+
42+
* Edit `docker-compose.yml` and change the variables.
43+
* Bring up the container:
44+
45+
```
46+
$ docker-compose up -d mariadb
47+
```
48+
49+
2. Open a terminal window within the container (see below) and change the values by hand.
50+
51+
> The how-to is beyond the scope of this documentation. Google is your friend!
2052

2153
## Terminal
2254

23-
A terminal is provided to access mariadb by the cli. execute `./services/mariadb/terminal.sh`. You will need to run `mysql -uroot -p` to enter mariadbs interface
55+
You can open a terminal session within the mariadb container via:
56+
57+
```
58+
$ docker exec -it mariadb bash
59+
```
60+
61+
To close the terminal session, either:
62+
63+
* type "exit" and press <kbd>return</kbd>; or
64+
* press <kbd>control</kbd>+<kbd>d</kbd>.
65+
66+
## Keeping MariaDB up-to-date
67+
68+
To update the `mariadb` container:
69+
70+
```
71+
$ cd ~/IOTstack
72+
$ docker-compose build --no-cache --pull mariadb
73+
$ docker-compose up -d mariadb
74+
$ docker system prune
75+
$ docker system prune
76+
```
77+
78+
The first "prune" removes the old *local* image, the second removes the old *base* image.

docs/Containers/NextCloud.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ nextcloud:
2323

2424
nextcloud_db:
2525
container_name: nextcloud_db
26-
image: ghcr.io/linuxserver/mariadb
26+
build: ./.templates/mariadb/.
2727
restart: unless-stopped
2828
environment:
2929
- TZ=Etc/UTC
@@ -33,8 +33,11 @@ nextcloud_db:
3333
- MYSQL_PASSWORD=«user_password»
3434
- MYSQL_DATABASE=nextcloud
3535
- MYSQL_USER=nextcloud
36+
ports:
37+
- "9322:3306"
3638
volumes:
3739
- ./volumes/nextcloud/db:/config
40+
- ./volumes/nextcloud/db_backup:/backup
3841
```
3942
4043
There are two containers, one for the cloud service itself, and the other for the database. Both containers share the same persistent storage area in the volumes subdirectory so they are treated as a unit. This will not interfere with any other MariaDB containers you might wish to run.
@@ -259,6 +262,29 @@ You can silence the warning by editing the Nextcloud service definition in `dock
259262

260263
Nextcloud traffic is not encrypted. Do **not** expose it to the web by opening a port on your home router. Instead, use a VPN like Wireguard to provide secure access to your home network, and let your remote clients access Nextcloud over the VPN tunnel.
261264

265+
## <a name="updatingNextcloud"> Keeping Nextcloud up-to-date </a>
266+
267+
To update the `nextcloud` container:
268+
269+
```
270+
$ cd ~/IOTstack
271+
$ docker-compose pull nextcloud
272+
$ docker-compose up -d nextcloud
273+
$ docker system prune
274+
```
275+
276+
To update the `nextcloud_db` container:
277+
278+
```
279+
$ cd ~/IOTstack
280+
$ docker-compose build --no-cache --pull nextcloud_db
281+
$ docker-compose up -d nextcloud_db
282+
$ docker system prune
283+
$ docker system prune
284+
```
285+
286+
The first "prune" removes the old *local* image, the second removes the old *base* image.
287+
262288
## <a name="backups"> Backups </a>
263289

264290
Nextcloud is currently excluded from the IOTstack-supplied backup scripts due to its potential size.

0 commit comments

Comments
 (0)