feat(docker): allow production docker setup to use dedicated mariadb

Signed-off-by: Steven Guikal <void@fluix.one>
This commit is contained in:
Steven Guikal 2021-10-19 15:23:00 -04:00
parent 4e3cc1dfe2
commit 1cb1ce0d99
4 changed files with 32 additions and 22 deletions

1
.env
View file

@ -1,2 +1,3 @@
FASTAPI_BACKEND="uvicorn" FASTAPI_BACKEND="uvicorn"
FASTAPI_WORKERS=2 FASTAPI_WORKERS=2
MARIADB_SOCKET_DIR="/var/run/mysqld/"

View file

@ -1,4 +1,24 @@
services: services:
mariadb:
image: aurweb:latest
init: true
entrypoint: /docker/mariadb-entrypoint.sh
command: /usr/bin/mysqld_safe --datadir=/var/lib/mysql
ports:
# This will expose mariadbd on 127.0.0.1:13306 in the host.
# Ex: `mysql -uaur -paur -h 127.0.0.1 -P 13306 aurweb`
- "13306:3306"
volumes:
- mariadb_run:/var/run/mysqld # Bind socket in this volume.
- mariadb_data:/var/lib/mysql
healthcheck:
test: "bash /docker/health/mariadb.sh"
mariadb_init:
depends_on:
mariadb:
condition: service_healthy
ca: ca:
volumes: volumes:
- ./cache:/cache - ./cache:/cache
@ -13,6 +33,9 @@ services:
- git_data:/aurweb/aur.git - git_data:/aurweb/aur.git
- ./cache:/cache - ./cache:/cache
- smartgit_run:/var/run/smartgit - smartgit_run:/var/run/smartgit
depends_on:
mariadb:
condition: service_healthy
php-fpm: php-fpm:
volumes: volumes:

View file

@ -9,6 +9,7 @@ services:
volumes: volumes:
- git_data:/aurweb/aur.git - git_data:/aurweb/aur.git
- cache:/cache - cache:/cache
- ${MARIADB_SOCKET_DIR}:/var/run/mysqld
smartgit: smartgit:
volumes: volumes:
@ -19,12 +20,18 @@ services:
php-fpm: php-fpm:
volumes: volumes:
- cache:/cache - cache:/cache
- ${MARIADB_SOCKET_DIR}:/var/run/mysqld
fastapi: fastapi:
environment: environment:
- FASTAPI_BACKEND="gunicorn" - FASTAPI_BACKEND="gunicorn"
volumes: volumes:
- cache:/cache - cache:/cache
- ${MARIADB_SOCKET_DIR}:/var/run/mysqld
mariadb_init:
volumes:
- ${MARIADB_SOCKET_DIR}:/var/run/mysqld
nginx: nginx:
volumes: volumes:
@ -34,7 +41,7 @@ services:
- smartgit_run:/var/run/smartgit - smartgit_run:/var/run/smartgit
volumes: volumes:
mariadb_run: {} # Share /var/run/mysqld/mysqld.sock mariadb_run: {} # Share /var/run/mysqld
mariadb_data: {} # Share /var/lib/mysql mariadb_data: {} # Share /var/lib/mysql
git_data: {} # Share aurweb/aur.git git_data: {} # Share aurweb/aur.git
smartgit_run: {} smartgit_run: {}

View file

@ -48,29 +48,11 @@ services:
ports: ports:
- "16379:6379" - "16379:6379"
mariadb:
image: aurweb:latest
init: true
entrypoint: /docker/mariadb-entrypoint.sh
command: /usr/bin/mysqld_safe --datadir=/var/lib/mysql
ports:
# This will expose mariadbd on 127.0.0.1:13306 in the host.
# Ex: `mysql -uaur -paur -h 127.0.0.1 -P 13306 aurweb`
- "13306:3306"
volumes:
- mariadb_run:/var/run/mysqld # Bind socket in this volume.
- mariadb_data:/var/lib/mysql
healthcheck:
test: "bash /docker/health/mariadb.sh"
mariadb_init: mariadb_init:
image: aurweb:latest image: aurweb:latest
init: true init: true
entrypoint: /docker/mariadb-init-entrypoint.sh entrypoint: /docker/mariadb-init-entrypoint.sh
command: echo "MariaDB tables initialized." command: echo "MariaDB tables initialized."
depends_on:
mariadb:
condition: service_healthy
volumes: volumes:
- mariadb_run:/var/run/mysqld - mariadb_run:/var/run/mysqld
@ -100,9 +82,6 @@ services:
command: /docker/scripts/run-smartgit.sh command: /docker/scripts/run-smartgit.sh
healthcheck: healthcheck:
test: "bash /docker/health/smartgit.sh" test: "bash /docker/health/smartgit.sh"
depends_on:
mariadb:
condition: service_healthy
cgit-php: cgit-php:
image: aurweb:latest image: aurweb:latest