diff --git a/.shogun/Dockerfile.dojo-basic-lite b/.shogun/Dockerfile.dojo-basic-lite index e4f884d..fcebdcd 100644 --- a/.shogun/Dockerfile.dojo-basic-lite +++ b/.shogun/Dockerfile.dojo-basic-lite @@ -11,7 +11,15 @@ RUN apt-get update && apt-get install -y \ # Set the environment variable for database type ENV DOJO_DB_TYPE=sqlite +# Create the db directory and set permissions +RUN mkdir -p /var/www/html/db && \ + chmod 755 /var/www/html/db + COPY ./src/basic /var/www/html + +# Run reset-db.php script +RUN php /var/www/html/reset-db.php + LABEL org.opencontainers.image.source=https://github.com/SamuraiWTF/samurai-dojo LABEL org.opencontainers.image.description="Basic PHP 7.4.27-apache-bullseye image with dojo-basic with sqlite support." LABEL org.opencontainers.image.licenses="lgpl" \ No newline at end of file diff --git a/src/basic/opendb.inc b/src/basic/opendb.inc index a3f8f77..e45f1a1 100644 --- a/src/basic/opendb.inc +++ b/src/basic/opendb.inc @@ -3,6 +3,7 @@ function db_connect() { global $db_type, $dbhost, $dbuser, $dbpass, $dbname; + $db_file = '/var/www/html/db/' . $dbname . '.sqlite'; if ($db_type === 'mysql') { $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname); @@ -10,7 +11,7 @@ function db_connect() { die("Connection failed: " . $conn->connect_error); } } else { - $conn = new SQLite3('/var/www/html/db/' . $dbname . '.sqlite'); + $conn = new SQLite3($db_file); } return $conn; diff --git a/src/basic/reset-db.php b/src/basic/reset-db.php index eda0b95..616354b 100644 --- a/src/basic/reset-db.php +++ b/src/basic/reset-db.php @@ -34,6 +34,7 @@ function execute_query($conn, $query) { $conn->select_db($dbname); } else { echo("
Setting up SQLite..."); + $db_file = '/var/www/html/db/' . $dbname . '.sqlite'; // Delete the existing database file if it exists