forked from kamba4/sunders
moved init to utils container
This commit is contained in:
parent
669c665a10
commit
985fbf7600
3 changed files with 17 additions and 0 deletions
|
@ -2,3 +2,4 @@ FROM docker.io/library/php:cli
|
||||||
|
|
||||||
RUN docker-php-ext-install mysqli bcmath
|
RUN docker-php-ext-install mysqli bcmath
|
||||||
COPY ./utils/* /opt/
|
COPY ./utils/* /opt/
|
||||||
|
COPY ./data_init/*.sql /opt/init/init.sql
|
||||||
|
|
2
create_db.sh
Normal file
2
create_db.sh
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
podman run --network tor -it --env MYSQL_USER=root --env MYSQL_PASSWD=my-secret-pw --env MYSQL_DATABASE=exmple-database --env MARIADB_ROOT_PASSWORD=my-secret-pw -e MYSQL_HOST=some-mariadb -e MYSQL_DB=sunders -e CAMERA_USER=cam -e CAMERA_USER_PASSWD=asdf1234 -e CAMERA_SELECT_USER=cam -e CAMERA_SELECT_USER_PASSWD=asdf1234 localhost/sunders-utils:latest php /opt/create_db.php
|
||||||
|
podman run --network tor -it --env MYSQL_USER=root --env MYSQL_PASSWD=my-secret-pw --env MYSQL_DATABASE=exmple-database --env MARIADB_ROOT_PASSWORD=my-secret-pw -e MYSQL_HOST=some-mariadb -e MYSQL_DB=sunders -e CAMERA_USER=cam -e CAMERA_USER_PASSWD=asdf1234 -e CAMERA_SELECT_USER=cam -e CAMERA_SELECT_USER_PASSWD=asdf1234 localhost/sunders-data_init:latest
|
|
@ -72,5 +72,19 @@ $conn->query("INSERT INTO sync_state (k, v) VALUES ('sequenceNumber', '0');");
|
||||||
|
|
||||||
echo "Database, users, and tables created successfully.\n";
|
echo "Database, users, and tables created successfully.\n";
|
||||||
|
|
||||||
|
$result = $conn -> query("SELECT * FROM position limit 10");
|
||||||
|
|
||||||
|
$table_count = $result -> num_rows;
|
||||||
|
|
||||||
|
printf("Result set has %d rows.\n", $table_count);
|
||||||
|
if ($table_count == 0){
|
||||||
|
$location = "/opt/init/init.sql";
|
||||||
|
|
||||||
|
$commands = file_get_contents($location);
|
||||||
|
$conn->multi_query($commands);
|
||||||
|
echo "Inserted data.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$conn->close();
|
$conn->close();
|
||||||
?>
|
?>
|
Loading…
Add table
Add a link
Reference in a new issue