Skip to content

Commit fcc05fa

Browse files
committed
Add MariaDB service
1 parent 828cad5 commit fcc05fa

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,5 @@ typings/
130130
# dotenv environment variables file
131131
.env
132132

133-
133+
### MariaDB
134+
/mariadb

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,21 @@ To stop the stack, run:
3535

3636
---
3737

38+
To connect to the MariaDB service, run:
39+
40+
docker-compose exec mariadb mysql -uapp -p
41+
42+
- This command uses the `app` user. There is also a `root` user.
43+
- Use the password defined on the `docker-compose.yml` file.
44+
45+
---
46+
3847
To install composer dependencies, run:
3948

4049
docker-compose run --rm composer install
4150

4251
- The `--rm` flag ensures that that intermediate (temporary) containers are deleted once you install packages (to save disk space).
52+
- The service's data is mounted on the `./mariadb` host folder, which means that data will persist between `docker-compose` `up`s and `stop`s.
4353

4454
---
4555

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
image: busybox:latest
66
volumes:
77
- ./:/var/www
8+
- ./mariadb:/var/lib/mysql:rw
89
php-fpm:
910
build:
1011
context: ./services/php
@@ -18,11 +19,26 @@ services:
1819
context: ./services/composer
1920
volumes:
2021
- ./:/app
22+
mariadb:
23+
build:
24+
context: ./services/mariadb
25+
ports:
26+
- 3306:3306
27+
volumes_from:
28+
- workspace
29+
environment:
30+
- "MYSQL_DATABASE=app"
31+
- "MYSQL_USER=app"
32+
- "MYSQL_PASSWORD=secret"
33+
- "MYSQL_ROOT_PASSWORD=secret"
2134
node:
2235
build:
2336
context: ./services/node
2437
volumes_from:
2538
- workspace
39+
2640
volumes:
2741
php-fpm:
2842
driver: "local"
43+
mariadb:
44+
driver: "local"

services/mariadb/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM mariadb:10.3
2+
3+
EXPOSE 3306
4+
5+
CMD ["mysqld"]

0 commit comments

Comments
 (0)