-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit mysql service * moved mysql service to it's own section in /src * moved mysql folder to src/databases/mysql * updated reusable workflow
- Loading branch information
Showing
7 changed files
with
59 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
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
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 |
---|---|---|
|
@@ -22,6 +22,8 @@ jobs: | |
name: loaders-curl | ||
- context: ./src/services/java | ||
name: services-java | ||
- context: ./src/databases/mysql | ||
name: databases-mysql | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
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
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 @@ | ||
FROM mysql:5.7 | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/cisco-open/app-simulator | ||
LABEL org.opencontainers.image.description="mysql database for app-simulator" | ||
LABEL org.opencontainers.image.licenses=BSD-3-Clause | ||
|
||
RUN yum install -y php-cli && yum clean all | ||
COPY setup.php /tmp/ | ||
COPY setup.sh /docker-entrypoint-initdb.d/ |
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,33 @@ | ||
<?php | ||
echo "Setup ...".PHP_EOL; | ||
|
||
$config = json_decode($_SERVER['APP_CONFIG']); | ||
|
||
$result = ""; | ||
|
||
foreach($config->databases as $database => $tables) { | ||
$result .= "CREATE DATABASE ".$database.";".PHP_EOL; | ||
$result .= "USE ".$database.";".PHP_EOL; | ||
foreach($tables as $table => $columns) { | ||
$result .="CREATE TABLE ".$table." (".PHP_EOL; | ||
foreach($columns as $column) { | ||
if($column === 'id') { | ||
$result .= " ".$column." INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,".PHP_EOL; | ||
} else { | ||
$result .= " ".$column. " VARCHAR(255),".PHP_EOL; | ||
} | ||
} | ||
|
||
$result = substr($result,0,-2).PHP_EOL; | ||
|
||
$result .=') ENGINE=InnoDB;'.PHP_EOL; | ||
} | ||
} | ||
|
||
echo '=====.PHP_EOL'; | ||
|
||
echo $result; | ||
|
||
echo '=====.PHP_EOL'; | ||
|
||
file_put_contents("/tmp/create.sql",$result); |
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,3 @@ | ||
#!/bin/bash | ||
APP_CONFIG="$(</config.json)" php /tmp/setup.php | ||
mysql -uroot -p${MYSQL_ROOT_PASSWORD} < /tmp/create.sql |