Files
jambotron/HELP.md
T

168 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
```
- For connection from pgadmin use
hostename: **host.docker.internal**
# How to run the application in Docker with HTTPS support
To run the application in Docker with HTTPS support, follow these steps:
1. **Cerbot**
- Run this command below to get certificate and store it to volume certs.
- Expanded(readable) command example:
docker run -d \
--name certbot \
-v certs:/etc/letsencrypt \
-v certs-data:/var/lib/letsencrypt \
-p 80:80 \
-p 443:443 \
certbot/certbot \
certonly --standalone --preferred-challenges http --email youremail@gmail.com -d yourdomain.com --agree-tos
- Command to run certbot with specific domain and email:
```bash
docker run -d --name certbot -v certs:/etc/letsencrypt -v certs-data:/var/lib/letsencrypt -p 8081:80 -p 8443:443 certbot/certbot certonly --standalone --preferred-challenges http --email liosha84@gmail.com -d jambotron.run.place --agree-tos
```
- Tip: You can generate certificate to local machine used next command:
```bash
docker run -it --rm -p 8081:80 --name certbot -v "C:\certbot\etc\letsencrypt:/etc/letsencrypt" -v "C:\certbot\var\lib\letsencrypt:/var/lib/letsencrypt" certbot/certbot certonly --standalone -d jambotron.run.place
```
certificate files will be stored in `C:\certbot\etc\letsencrypt` and `C:\certbot\var\lib\letsencrypt` directories.
- If you have same trouble before running certbot, run this project
`Helper_projects/spring-boot-https-main` insted of jambotron project.
- TODO: Add cron job to renew certificate automatically.
### 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