diff --git a/.gitignore b/.gitignore index e5f7cfe..cfbc25f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -HELP.md + .gradle build/ !gradle/wrapper/gradle-wrapper.jar diff --git a/HELP.md b/HELP.md new file mode 100644 index 0000000..7f9f0f5 --- /dev/null +++ b/HELP.md @@ -0,0 +1,129 @@ + +# How to run the application + +To run the application, follow these steps: + +1. **Build the Project**: + - Ensure you have Java 24, Gradle, and Node.js installed. + - Run the following command to build the project: + ```bash + ./gradlew build + ``` + + 2. **Prepare Frontend Resources**: + - Build the Angular frontend by navigating to the `jambotron-ui` directory and running + ```bash + cd jambotron-ui + ``` + - next: + ```bash + npm install + ``` + - next: + ```bash + npm run build + ``` + - This will generate the frontend files in the `jambotron-ui/dist/jambotron-ui/browser` directory. + + +3. **Copy Frontend Resources**: + - Use the Gradle task to copy the frontend resources to the `jumbotron/src/main/resources/public` directory: + ```bash + cd .. + ``` + - next: + ```bash + ./gradlew copyResources + ``` + then +4. **Create postgres server and database**: + - Create a PostgreSQL database + - named `jambotronDB` with the + - user `admin` and + - password `postgrespw`. + + - You can use a PostgreSQL client or run the following command in your terminal: + ```sql + CREATE DATABASE jambotronDB; + CREATE USER admin WITH PASSWORD 'postgrespw'; + GRANT ALL PRIVILEGES ON DATABASE jambotronDB TO admin; + ``` + - If you are using Docker, you can run PostgreSQL using the following command: + ```bash + docker run --name postgresDB -p 5432:5432 -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=postgrespw -e POSTGRES_DB=jambotronDB -d postgres + ``` + - if you are wont to use pgadmin + ```bash + docker run --name pgadmin -e "PGADMIN_DEFAULT_EMAIL=name@example.com" -e "PGADMIN_DEFAULT_PASSWORD=admin" -p 5050:80 -d dpage/pgadmin4 + ``` + then + - create a network for the containers to communicate: + ```bash + docker network create --driver bridge pgnetwork + ``` + - Show list of networks: + ```bash + docker network ls + ``` + - Connect pgadmin to the network: + ```bash + docker network connect pgnetwork pgadmin + ``` + - Connect postgresDB to the network (postgresDB must by running): + ```bash + docker network connect pgnetwork postgresDB + ``` + - Inspect the network to ensure both containers are connected: + ```bash + docker network inspect pgnetwork + ``` + + + +5. **Run the Application**: + - Start the Spring Boot application: + ```bash + ./gradlew bootRun + ``` + +6. **Access the Application**: + - Open your browser and navigate to `http://localhost:8080`. + +Make sure all dependencies and configurations are correctly set up before running these steps. + + + + +# How to run the application in Docker + +To run the application in Docker, follow these steps: + +- build jar file +```bash +./gradlew bootJar + ``` +- Run docker compose to start the application and PostgreSQL: +```bash +docker-compose -f src/Docker/docker-compose.yml up -d +``` +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Gradle documentation](https://docs.gradle.org) +* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/3.5.0/gradle-plugin) +* [Create an OCI image](https://docs.spring.io/spring-boot/3.5.0/gradle-plugin/packaging-oci-image.html) + +### Additional Links +These additional references should also help you: + +* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) + + + +For docker-compose db connect with pgAdmin used +host.docker.internal + + + + + diff --git a/jambotron-ui/angular.json b/jambotron-ui/angular.json index 6260ea7..07de4b3 100644 --- a/jambotron-ui/angular.json +++ b/jambotron-ui/angular.json @@ -44,7 +44,7 @@ { "type": "initial", "maximumWarning": "500kB", - "maximumError": "1MB" + "maximumError": "5MB" }, { "type": "anyComponentStyle", @@ -105,4 +105,4 @@ } } } -} \ No newline at end of file +} diff --git a/jambotron-ui/public/Firefly_jambo-tron-118290.ico b/jambotron-ui/public/Firefly_jambo-tron-118290.ico new file mode 100644 index 0000000..7a97d40 Binary files /dev/null and b/jambotron-ui/public/Firefly_jambo-tron-118290.ico differ diff --git a/jambotron-ui/src/index.html b/jambotron-ui/src/index.html index 44d8f23..702379c 100644 --- a/jambotron-ui/src/index.html +++ b/jambotron-ui/src/index.html @@ -5,7 +5,9 @@ JambotronUi - + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4006651 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "jambotron", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/src/Docker/docker-compose.yml b/src/Docker/docker-compose.yml index eb40984..bf8728d 100644 --- a/src/Docker/docker-compose.yml +++ b/src/Docker/docker-compose.yml @@ -1,6 +1,6 @@ services: - app: - image: 'jambotron' + jambotron: + image: 'jambotron-image' container_name: 'jambotron-container' build: context: ../../ @@ -26,7 +26,7 @@ services: postgres_jambotron: - image: 'postgres:13-alpine' + image: 'postgres' container_name: 'jambotron-postgres-container' ports: - "5432:5432" diff --git a/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java b/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java index facdcb8..260f19b 100644 --- a/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java +++ b/src/main/java/com/jambotronGroup/jambotron/configuretions/MvcConfig.java @@ -12,6 +12,8 @@ public class MvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/public/**").addResourceLocations(resourceLocations); + //registry.addResourceHandler("/public/**").addResourceLocations(resourceLocations); + // registry.addResourceHandler("/media/**").addResourceLocations("resources/main/public/media/"); + } } diff --git a/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java b/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java index 2965bbd..101b6d1 100644 --- a/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java +++ b/src/main/java/com/jambotronGroup/jambotron/configuretions/NotFoundHandler.java @@ -14,6 +14,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.nio.charset.Charset; +/* @ControllerAdvice public class NotFoundHandler { @@ -32,4 +33,4 @@ public class NotFoundHandler { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There was an error completing the action."); } } -} \ No newline at end of file +}*/ diff --git a/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java b/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java index 8b50eaa..1d1df36 100644 --- a/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java +++ b/src/main/java/com/jambotronGroup/jambotron/security/WebSecurityConfig.java @@ -105,6 +105,8 @@ public class WebSecurityConfig {// extends WebSecurityConfigurerAdapter { .authorizeHttpRequests(auth -> auth.requestMatchers("/api/auth/**").permitAll() .requestMatchers("/*", "/home", "/resources/**").permitAll() + .requestMatchers("/resources/public/media/**").permitAll() + .requestMatchers("/media/**").permitAll() .requestMatchers("/api/test/**").permitAll() .requestMatchers("/api/tutorials").permitAll()