Skip to content

Commit 17fccc3

Browse files
authored
Merge pull request #412 from jolicode/mariadb-cookbook
Update cookbook for MariaDB and MySQL
2 parents 2aa0240 + b283aad commit 17fccc3

1 file changed

Lines changed: 69 additions & 140 deletions

File tree

‎README.md‎

Lines changed: 69 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -163,86 +163,84 @@ Usually, there is three places where you need to do it:
163163
In order to use MariaDB, you will need to apply this patch:
164164

165165
```diff
166-
diff --git a/infrastructure/docker/docker-compose.builder.yml b/infrastructure/docker/docker-compose.builder.yml
167-
index d00f315..bdfdc65 100644
168-
--- a/infrastructure/docker/docker-compose.builder.yml
169-
+++ b/infrastructure/docker/docker-compose.builder.yml
170-
@@ -10,7 +10,7 @@ services:
171-
builder:
172-
build: services/builder
173-
depends_on:
174-
- - postgres
175-
+ - mariadb
166+
diff --git a/infrastructure/docker/docker-compose.yml b/infrastructure/docker/docker-compose.yml
167+
index e891ada..a49a99d 100644
168+
--- a/infrastructure/docker/docker-compose.yml
169+
+++ b/infrastructure/docker/docker-compose.yml
170+
@@ -8,7 +8,7 @@ x-templates:
176171
environment:
177-
- COMPOSER_MEMORY_LIMIT=-1
178-
volumes:
179-
diff --git a/infrastructure/docker/docker-compose.worker.yml b/infrastructure/docker/docker-compose.worker.yml
180-
index 2eda814..59f8fed 100644
181-
--- a/infrastructure/docker/docker-compose.worker.yml
182-
+++ b/infrastructure/docker/docker-compose.worker.yml
183-
@@ -5,7 +5,7 @@ x-services-templates:
184-
worker_base: &worker_base
185-
build: services/worker
172+
- APP_ENV
186173
depends_on:
187-
- - postgres
188-
+ - mariadb
189-
#- rabbitmq
174+
- postgres:
175+
+ mariadb:
176+
condition: service_healthy
190177
volumes:
191178
- "../..:/var/www:cached"
192-
diff --git a/infrastructure/docker/docker-compose.yml b/infrastructure/docker/docker-compose.yml
193-
index 49a2661..1804a01 100644
194-
--- a/infrastructure/docker/docker-compose.yml
195-
+++ b/infrastructure/docker/docker-compose.yml
196-
@@ -1,7 +1,7 @@
197-
version: '3.7'
179+
@@ -16,23 +16,25 @@ x-templates:
180+
- worker
198181

199182
volumes:
200183
- postgres-data: {}
201184
+ mariadb-data: {}
185+
# # Needed if $XDG_ env vars have been overridden
186+
# builder-yarn-data: {}
202187

203188
services:
204-
router:
205-
@@ -13,7 +13,7 @@ services:
206-
frontend:
207-
build: services/frontend
208-
depends_on:
209-
- - postgres
210-
+ - mariadb
211-
volumes:
212-
- "../..:/var/www:cached"
213-
labels:
214-
@@ -24,10 +24,7 @@ services:
215-
# Comment the next line to be able to access frontend via HTTP instead of HTTPS
216-
- "traefik.http.routers.${PROJECT_NAME}-frontend-unsecure.middlewares=redirect-to-https@file"
217-
218189
- postgres:
219190
- image: postgres:16
220-
- environment:
191+
+ mariadb:
192+
+ image: mariadb:12
193+
environment:
221194
- - POSTGRES_USER=app
222195
- - POSTGRES_PASSWORD=app
223-
+ mariadb:
224-
+ image: mariadb:11
225-
+ environment:
196+
- volumes:
197+
- - postgres-data:/var/lib/postgresql/data
226198
+ - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1
227-
+ healthcheck:
199+
+ - MARIADB_USER=app
200+
+ - MARIADB_PASSWORD=app
201+
+ - MARIADB_DATABASE=app
202+
healthcheck:
203+
- test: ["CMD-SHELL", "pg_isready -U postgres"]
228204
+ test: "mariadb-admin ping -h localhost"
229-
+ interval: 5s
230-
+ timeout: 5s
205+
interval: 5s
206+
timeout: 5s
207+
- retries: 5
231208
+ retries: 10
232-
volumes:
233-
- - postgres-data:/var/lib/postgresql/data
209+
+ volumes:
234210
+ - mariadb-data:/var/lib/mysql
211+
profiles:
212+
- default
213+
214+
@@ -49,7 +51,7 @@ services:
215+
- "../..:/var/www:cached"
216+
- "../../.home:/home/app:cached"
217+
depends_on:
218+
- postgres:
219+
+ mariadb:
220+
condition: service_healthy
221+
profiles:
222+
- default
223+
@@ -90,6 +92,6 @@ services:
224+
# of $XDG_DATA_HOME
225+
# - "builder-yarn-data:/data/yarn"
226+
depends_on:
227+
- - postgres
228+
+ - mariadb
229+
profiles:
230+
- builder
235231
diff --git a/infrastructure/docker/services/php/Dockerfile b/infrastructure/docker/services/php/Dockerfile
236-
index 56e1835..95fee78 100644
232+
index e9e95fd..8f00745 100644
237233
--- a/infrastructure/docker/services/php/Dockerfile
238234
+++ b/infrastructure/docker/services/php/Dockerfile
239-
@@ -24,7 +24,7 @@ RUN apk add --no-cache \
240-
php${PHP_VERSION}-intl \
241-
php${PHP_VERSION}-mbstring \
242-
- php${PHP_VERSION}-pgsql \
243-
+ php${PHP_VERSION}-mysql \
244-
php${PHP_VERSION}-xml \
245-
php${PHP_VERSION}-zip \
235+
@@ -35,7 +35,7 @@ RUN apt-get update \
236+
"php${PHP_VERSION}-iconv" \
237+
"php${PHP_VERSION}-intl" \
238+
"php${PHP_VERSION}-mbstring" \
239+
- "php${PHP_VERSION}-pgsql" \
240+
+ "php${PHP_VERSION}-mysql" \
241+
"php${PHP_VERSION}-uuid" \
242+
"php${PHP_VERSION}-xml" \
243+
"php${PHP_VERSION}-zip" \
246244
```
247245

248246
</details>
@@ -253,89 +251,20 @@ index 56e1835..95fee78 100644
253251

254252
<summary>Read the cookbook</summary>
255253

256-
In order to use MySQL, you will need to apply this patch:
257-
258-
```diff
259-
diff --git a/infrastructure/docker/docker-compose.builder.yml b/infrastructure/docker/docker-compose.builder.yml
260-
index d00f315..bdfdc65 100644
261-
--- a/infrastructure/docker/docker-compose.builder.yml
262-
+++ b/infrastructure/docker/docker-compose.builder.yml
263-
@@ -10,7 +10,7 @@ services:
264-
builder:
265-
build: services/builder
266-
depends_on:
267-
- - postgres
268-
+ - mysql
269-
environment:
270-
- COMPOSER_MEMORY_LIMIT=-1
271-
volumes:
272-
diff --git a/infrastructure/docker/docker-compose.worker.yml b/infrastructure/docker/docker-compose.worker.yml
273-
index 2eda814..59f8fed 100644
274-
--- a/infrastructure/docker/docker-compose.worker.yml
275-
+++ b/infrastructure/docker/docker-compose.worker.yml
276-
@@ -5,7 +5,7 @@ x-services-templates:
277-
worker_base: &worker_base
278-
build: services/worker
279-
depends_on:
280-
- - postgres
281-
+ - mysql
282-
#- rabbitmq
283-
volumes:
284-
- "../..:/var/www:cached"
285-
diff --git a/infrastructure/docker/docker-compose.yml b/infrastructure/docker/docker-compose.yml
286-
index 49a2661..1804a01 100644
287-
--- a/infrastructure/docker/docker-compose.yml
288-
+++ b/infrastructure/docker/docker-compose.yml
289-
@@ -1,7 +1,7 @@
290-
version: '3.7'
291-
292-
volumes:
293-
- postgres-data: {}
294-
+ mysql-data: {}
254+
In order to use MySQL, you will need to follow the same steps as for MariaDB, but with the following configuration for the database service:
295255

296-
services:
297-
router:
298-
@@ -13,7 +13,7 @@ services:
299-
frontend:
300-
build: services/frontend
301-
depends_on:
302-
- - postgres
303-
+ - mysql
304-
volumes:
305-
- "../..:/var/www:cached"
306-
labels:
307-
@@ -24,10 +24,7 @@ services:
308-
# Comment the next line to be able to access frontend via HTTP instead of HTTPS
309-
- "traefik.http.routers.${PROJECT_NAME}-frontend-unsecure.middlewares=redirect-to-https@file"
310-
311-
- postgres:
312-
- image: postgres:16
313-
- environment:
314-
- - POSTGRES_USER=app
315-
- - POSTGRES_PASSWORD=app
316-
+ mysql:
317-
+ image: mysql:8
318-
+ environment:
319-
+ - MYSQL_ALLOW_EMPTY_PASSWORD=1
320-
+ healthcheck:
321-
+ test: "mysqladmin ping -h localhost"
322-
+ interval: 5s
323-
+ timeout: 5s
324-
+ retries: 10
256+
```
257+
mysql:
258+
image: mysql:8
259+
environment:
260+
- MYSQL_ALLOW_EMPTY_PASSWORD=1
261+
healthcheck:
262+
test: "mysqladmin ping -h localhost"
263+
interval: 5s
264+
timeout: 5s
265+
retries: 10
325266
volumes:
326-
- - postgres-data:/var/lib/postgresql/data
327-
+ - mysql-data:/var/lib/mysql
328-
diff --git a/infrastructure/docker/services/php/Dockerfile b/infrastructure/docker/services/php/Dockerfile
329-
index 56e1835..95fee78 100644
330-
--- a/infrastructure/docker/services/php/Dockerfile
331-
+++ b/infrastructure/docker/services/php/Dockerfile
332-
@@ -24,7 +24,7 @@ RUN apk add --no-cache \
333-
php${PHP_VERSION}-intl \
334-
php${PHP_VERSION}-mbstring \
335-
- php${PHP_VERSION}-pgsql \
336-
+ php${PHP_VERSION}-mysql \
337-
php${PHP_VERSION}-xml \
338-
php${PHP_VERSION}-zip \
267+
- mysql-data:/var/lib/mysql
339268
```
340269

341270
</details>

0 commit comments

Comments
 (0)