From e31b5c4a63a0a9fa314740fb8ab4ef29a7389bf2 Mon Sep 17 00:00:00 2001 From: bryce Date: Tue, 5 Nov 2024 21:40:18 +1300 Subject: [PATCH] Start MSQL Schema and config the YML for docker the 'special' words are in properties file. --- BrickLog-Server/sql/schema.sql | 4 +-- BrickLog-Server/src/docker-compose.yml | 29 ++++--------------- .../java/resources/application.properties | 9 +++--- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/BrickLog-Server/sql/schema.sql b/BrickLog-Server/sql/schema.sql index 725a992..8fbb302 100644 --- a/BrickLog-Server/sql/schema.sql +++ b/BrickLog-Server/sql/schema.sql @@ -3,13 +3,13 @@ CREATE DATABASE bricklog_db GO -- Grant Permissions & Flush -GRANT ALL PERMISSIONS TO bl_server IDENTIFIED BY l3g0D3t41l$h3r3 +GRANT ALL PERMISSIONS TO bl_server GO -- Create a new table called 'collection_table' in schema 'bricklog_db' -- Create the table in the specified schema CREATE TABLE lego_builds ( - id INT NOT NULL PRIMARY KEY, -- Lego Build ID can be used here (hence not Auto_increment) + legoId INT NOT NULL PRIMARY KEY, -- Lego Build ID can be used here (hence not Auto_increment) builder VARCHAR(255) NOT NULL, buildName VARCHAR(255) NOT NULL, is_kitset BOOLEAN NOT NULL, diff --git a/BrickLog-Server/src/docker-compose.yml b/BrickLog-Server/src/docker-compose.yml index c417cce..0f726eb 100644 --- a/BrickLog-Server/src/docker-compose.yml +++ b/BrickLog-Server/src/docker-compose.yml @@ -1,29 +1,12 @@ version: '0.1' services: - bricklog-server: + bricklog_server: + container_name: BrickLog_Server build: - context: ./BrickLog-Server + context: . dockerfile: Dockerfile ports: - - "8080:8080" # Adjust based on your server's port - environment: - - SPRING_DATASOURCE_URL=jdbc:mariadb://db:3306/bricklog - - SPRING_DATASOURCE_USERNAME=bl_server - - SPRING_DATASOURCE_PASSWORD=l3g0D3t41l$h3r3 - depends_on: - - db # Ensure the database starts before the server - - db: - image: mysql:8.0 - restart: always - environment: - MYSQL_DATABASE: bricklog - MYSQL_ROOT_PASSWORD: root # Set a strong password in production - ports: - - "3306:3306" # Expose MySQL port - volumes: - - db_data:/var/lib/mysql # Persist database data - -volumes: - db_data: + - "8080:8080" # Expose the application on port 8080 + extra_hosts: + - "host.docker.internal:host-gateway" # Enables access to the host's MariaDB instance \ No newline at end of file diff --git a/BrickLog-Server/src/main/java/resources/application.properties b/BrickLog-Server/src/main/java/resources/application.properties index a1ade11..1db829b 100644 --- a/BrickLog-Server/src/main/java/resources/application.properties +++ b/BrickLog-Server/src/main/java/resources/application.properties @@ -1,7 +1,8 @@ -# MariaDB Configuration -spring.datasource.url=jdbc:mariadb://localhost:3306/bricklog_db -spring.datasource.username=your_db_username -spring.datasource.password=your_db_password +# Database configuration +spring.datasource.url=jdbc:mariadb://host.docker.internal:3306/bricklog +spring.datasource.username=bricklog +spring.datasource.password=your_password_here + # JPA settings spring.jpa.hibernate.ddl-auto=update # Creates tables automatically; set to 'none' in production if not needed