-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trivial implementation of automated schema/user creation - just good …
…enough for dev.
- Loading branch information
Duty Human
committed
Oct 2, 2022
1 parent
cfd2934
commit dbc3476
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
/usr/local/bin/docker-gen mariadb.tmpl /tmp/sql.sh | ||
while true; | ||
do | ||
ls -l /tmp/sql.sh | ||
source /tmp/sql.sh | ||
/usr/local/bin/docker-gen --watch mariadb.tmpl /tmp/sql.sh | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM jwilder/docker-gen AS docker-gen | ||
FROM mariadb:latest | ||
COPY --from=docker-gen /usr/local/bin/docker-gen /usr/local/bin/docker-gen | ||
COPY mariadb-entrypoint.sh / | ||
COPY mariadb.tmpl / | ||
ENTRYPOINT ["/mariadb-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
{{ range $index, $value := . }} | ||
|
||
{{ if $value.Env.DB_HOST }} | ||
# TODO: Save password from dbserver startup into files then read config | ||
/usr/bin/mysql -h{{$value.Env.DB_HOST}} -ppass -e ' | ||
CREATE USER IF NOT EXISTS `{{$value.Env.DB_USER}}` IDENTIFIED BY "{{$value.Env.DB_PASS}}"; | ||
CREATE SCHEMA IF NOT EXISTS `{{$value.Env.DB_SCHEMA}}`; | ||
GRANT ALL ON `{{$value.Env.DB_SCHEMA}}`.* TO `{{$value.Env.DB_USER}}`@`%`; | ||
' | ||
{{ end }} | ||
{{end}} |