diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000000000000000000000000000000000..1be74ad9b53564c23e02766b5e4baee4a99c4eaf --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +DB_HOST=db +DB_NAME=mahasiswa_leveling +DB_PORT=3307 +DB_USER=u1 +DB_PASSWORD=a +WEB_PORT=6666 +PHPMYADMIN_PORT=8001 \ No newline at end of file diff --git a/config/.env.example b/config/.env.example deleted file mode 100644 index e24e01a5ed0f5fa9f258d5ede421ae8c02f8e931..0000000000000000000000000000000000000000 --- a/config/.env.example +++ /dev/null @@ -1,7 +0,0 @@ -DB_HOST=db -DB_NAME=dabest -DB_PORT=3306 -DB_USER=willy -DB_PASSWORD=duar -WEB_PORT=8080 -PHPMYADMIN_PORT=8001 \ No newline at end of file diff --git a/config/config.php b/config/config.php index 8f4e1d4ffcf8a5ce11bc4d62d7a90ad0fecaa7ce..80d3c7dcad721f1b28983523d08915cbe86fd390 100644 --- a/config/config.php +++ b/config/config.php @@ -1,7 +1,7 @@ <?php require_once 'dotenv.php'; -(new DotEnv(__DIR__ .'/.env'))->load(); +(new DotEnv(__DIR__ .'/../.env'))->load(); define('BASEURL', getenv('BASEURL')); define('DB_HOST', getenv('DB_HOST')); diff --git a/config/db_config.php b/config/db_config.php deleted file mode 100644 index 3adecd383e05014d5181c8169875c55600a04145..0000000000000000000000000000000000000000 --- a/config/db_config.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -// Database connection -$server = "localhost:3308"; // NOTE: ini 3308 port yang dipake Willy, defaultnya 3306 -$username = "root"; -$password = ""; -$database = "Mahasiswa_Leveling"; - -$conn = new mysqli($server, $username, $password); -if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); -} - -$query = "CREATE DATABASE IF NOT EXISTS $database"; -$conn->query($query); -$conn->close(); - -$conn = new mysqli($server, $username, $password, $database); -if ($conn->connect_error) { - die("Connection failed: " . $conn->connect_error); -} - -$tableExists = $conn->query("SHOW TABLES LIKE 'users'"); -if ($tableExists->num_rows == 0) { - // Table doesn't exist, so create it - $createTableSQL = "CREATE TABLE users ( - id INT PRIMARY KEY AUTO_INCREMENT, - username TEXT NOT NULL, - email TEXT NOT NULL, - password TEXT NOT NULL, - isAdmin INT DEFAULT 0 - )"; - $conn->query($createTableSQL); -} - -?> \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c6a942effd7896c83d33c915a93b11700d3475ad..e9e6056650a45c31a206d4b0871b57f65ea69c6d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,25 +1,33 @@ version: '3.3' services: - www: + mhslvl-app: image: php:8.0-apache volumes: - - "./:/var/www/html" # sync project dir with container + - "./:/var/www/html" ports: - - ${WEB_PORT}:80 + - 8080:80 - 443:443 - db: - image: mysql:latest - environment: - - MYSQL_DATABASE=${DB_NAME} - - MYSQL_USER=${DB_USER} - - MYSQL_PASSWORD=${DB_PASSWORD} # this should live in a env var - - MYSQL_ALLOW_EMPTY_PASSWORD=1 # equivalent to True - volumes: - - "./db:/docker-entrypoint-initdb.d" # sync persistent sql files with container - phpmyadmin: - image: phpmyadmin/phpmyadmin - ports: - - ${PHPMYADMIN_PORT}:80 - environment: - - PMA_HOST=${DB_HOST} - - PMA_PORT=${DB_PORT} \ No newline at end of file + env_file: + - .env + + # mhslvl-app-db: + # image: mysql:latest + # ports: + # - ${DB_PORT}:3306 + # environment: + # - MYSQL_DATABASE=${DB_NAME} + # - MYSQL_USER=${DB_USER} + # - MYSQL_PASSWORD=${DB_PASSWORD} + # - MYSQL_ALLOW_EMPTY_PASSWORD=1 + # volumes: + # - "./db:/docker-entrypoint-initdb.d" + + # phpmyadmin: + # image: phpmyadmin/phpmyadmin + # env_file: + # - .env + # ports: + # - ${PHPMYADMIN_PORT}:80 + # environment: + # - PMA_HOST=${DB_HOST} + # - PMA_PORT=${DB_PORT} \ No newline at end of file