mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
refactor(docker): New mariadb_init service
Provides a single source of truth for mariadb database initialization. Previously, php-fpm and fastapi were racing against each other; while this wasn't an issue, it was very messy. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
2e3f69ab12
commit
0fd31b8d36
5 changed files with 64 additions and 40 deletions
|
@ -1,11 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
dir="$(dirname $0)"
|
||||
|
||||
bash $dir/test-mysql-entrypoint.sh
|
||||
[[ -z "$DB_HOST" ]] && echo 'Error: $DB_HOST required but missing.' && exit 1
|
||||
|
||||
DB_NAME="aurweb"
|
||||
DB_USER="aur"
|
||||
DB_PASS="aur"
|
||||
|
||||
# Setup a config for our mysql db.
|
||||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
sed -ri "s/^(name) = .+/\1 = ${DB_NAME}/" conf/config
|
||||
sed -ri "s/^(host) = .+/\1 = ${DB_HOST}/" conf/config
|
||||
sed -ri "s/^(user) = .+/\1 = ${DB_USER}/" conf/config
|
||||
sed -ri "s/^;?(password) = .+/\1 = ${DB_PASS}/" conf/config
|
||||
|
||||
sed -ri "s;^(aur_location) = .+;\1 = https://localhost:8444;" conf/config
|
||||
sed -ri 's/^(name) = .+/\1 = aurweb/' conf/config
|
||||
|
||||
# Setup Redis for FastAPI.
|
||||
sed -ri 's/^(cache) = .+/\1 = redis/' conf/config
|
||||
|
@ -14,7 +24,4 @@ sed -ri 's|^(redis_address) = .+|\1 = redis://redis|' conf/config
|
|||
sed -ri "s|^(git_clone_uri_anon) = .+|\1 = https://localhost:8444/%s.git|" conf/config.defaults
|
||||
sed -ri "s|^(git_clone_uri_priv) = .+|\1 = ssh://aur@localhost:2222/%s.git|" conf/config.defaults
|
||||
|
||||
# Initialize the new database; ignore errors.
|
||||
python -m aurweb.initdb 2>/dev/null || /bin/true
|
||||
|
||||
exec "$@"
|
||||
|
|
|
@ -3,8 +3,6 @@ set -eou pipefail
|
|||
|
||||
MYSQL_DATA=/var/lib/mysql
|
||||
|
||||
[[ -z "$DB_HOST" ]] && DB_HOST="localhost"
|
||||
|
||||
mariadb-install-db --user=mysql --basedir=/usr --datadir=$MYSQL_DATA
|
||||
|
||||
# Start it up.
|
||||
|
|
20
docker/mariadb-init-entrypoint.sh
Executable file
20
docker/mariadb-init-entrypoint.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
[[ -z "$DB_HOST" ]] && echo 'Error: $DB_HOST required but missing.' && exit 1
|
||||
|
||||
DB_NAME="aurweb"
|
||||
DB_USER="aur"
|
||||
DB_PASS="aur"
|
||||
|
||||
# Setup a config for our mysql db.
|
||||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
sed -ri "s/^(name) = .+/\1 = ${DB_NAME}/" conf/config
|
||||
sed -ri "s/^(host) = .+/\1 = ${DB_HOST}/" conf/config
|
||||
sed -ri "s/^(user) = .+/\1 = ${DB_USER}/" conf/config
|
||||
sed -ri "s/^;?(password) = .+/\1 = ${DB_PASS}/" conf/config
|
||||
|
||||
python -m aurweb.initdb 2>/dev/null || /bin/true
|
||||
|
||||
exec "$@"
|
|
@ -1,11 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
dir="$(dirname $0)"
|
||||
|
||||
bash $dir/test-mysql-entrypoint.sh
|
||||
[[ -z "$DB_HOST" ]] && echo 'Error: $DB_HOST required but missing.' && exit 1
|
||||
|
||||
DB_NAME="aurweb"
|
||||
DB_USER="aur"
|
||||
DB_PASS="aur"
|
||||
|
||||
# Setup a config for our mysql db.
|
||||
cp -vf conf/config.dev conf/config
|
||||
sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config
|
||||
sed -ri "s/^(name) = .+/\1 = ${DB_NAME}/" conf/config
|
||||
sed -ri "s/^(host) = .+/\1 = ${DB_HOST}/" conf/config
|
||||
sed -ri "s/^(user) = .+/\1 = ${DB_USER}/" conf/config
|
||||
sed -ri "s/^;?(password) = .+/\1 = ${DB_PASS}/" conf/config
|
||||
|
||||
sed -ri "s;^(aur_location) = .+;\1 = https://localhost:8443;" conf/config
|
||||
sed -ri 's/^(name) = .+/\1 = aurweb/' conf/config
|
||||
|
||||
# Enable memcached.
|
||||
sed -ri 's/^(cache) = .+$/\1 = memcache/' conf/config
|
||||
|
@ -27,6 +37,4 @@ sed -ri 's/^;?(open_basedir).*$/\1 = \//' /etc/php/php.ini
|
|||
# Use the sqlite3 extension line for memcached.
|
||||
sed -ri 's/^;(extension)=sqlite3$/\1=memcached/' /etc/php/php.ini
|
||||
|
||||
python -m aurweb.initdb 2>/dev/null || /bin/true
|
||||
|
||||
exec "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue