Skip to content

Commit

Permalink
create testing db if DB_DATABASE_TEST is set
Browse files Browse the repository at this point in the history
  • Loading branch information
bpow committed Dec 21, 2023
1 parent d370b2f commit 54eb635
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .docker/mysql/db-init/create_testing_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -eo pipefail
shopt -s nullglob

if [[ ! -v DB_DATABASE_TEST ]]; then
echo '$DB_DATABASE_TEST is not defined, skipping testing db creation'
else

source /usr/local/bin/docker-entrypoint.sh

docker_process_sql --database=mysql <<EOSQL
CREATE DATABASE IF NOT EXISTS ${DB_DATABASE_TEST};
GRANT ALL ON ${DB_DATABASE_TEST}.* TO '${MYSQL_USER:-ccdb}'@'%';
EOSQL
fi
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_SORT_BUFFER_SIZE=256000000
- DB_DATABASE_TEST=testing
user: ${DOCKER_USER:-501:20}

app:
Expand Down

0 comments on commit 54eb635

Please sign in to comment.