-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Establish the properties required to execute * Setup the Dockerfile and the Compose file * Create the Entity, Repository and Controller classes * Create the Style file and the View HTML files * Fix a few bugs and improve the codebase * Optimize the Dockerfile and the Compose file * Add reverse proxy using Nginx Image * Add some basic documentation to the README.md file
- Loading branch information
Showing
19 changed files
with
879 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
MYSQLDB_USER=root | ||
MYSQLDB_ROOT_PASSWORD=p4$$w0rd | ||
|
||
MYSQLDB_DATABASE=todos-db | ||
|
||
MYSQLDB_LOCAL_PORT=4242 | ||
MYSQLDB_DOCKER_PORT=3306 | ||
|
||
SPRING_LOCAL_PORT=6969 | ||
SPRING_DOCKER_PORT=8080 | ||
|
||
NGINX_LOCAL_PORT=99 | ||
NGINX_DOCKER_PORT=80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.m2/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
|
@@ -6,4 +7,4 @@ | |
*.ipr | ||
|
||
### VS Code ### | ||
.vscode/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,98 @@ | ||
# todos-box | ||
# Todos Application | ||
|
||
This *application* is used to **manage** your *day-to-day* or even *long-term* **todos**! | ||
|
||
<hr/> | ||
|
||
## Requirements | ||
|
||
The **stable** releases of the following *technologies* are used: | ||
|
||
| Technology | Version | | ||
| ----------- | ------- | | ||
| JDK | 17+ | | ||
| Spring Boot | 3.0+ | | ||
| Lombok | 1.18+ | | ||
| MySQL | 8.0+ | | ||
| Maven | 3.8+ | | ||
| Thymeleaf | 3.1+ | | ||
| Bootstrap | 4.6+ | | ||
| jQuery | 3.6+ | | ||
| Docker | 20+ | | ||
|
||
P.S. For *production* purposes, only **Docker** is *sufficient*. | ||
|
||
<hr/> | ||
|
||
## Development | ||
|
||
The *database* can be **monitored** as follows: | ||
|
||
### Usage | ||
|
||
**Run** the following *command* for Docker **Container**: | ||
|
||
>docker run --detach --env MYSQL_ROOT_PASSWORD=dev-root --env MYSQL_USER=dev-user --env MYSQL_PASSWORD=dev-pass --env MYSQL_DATABASE=dev-todos --name dev-db --publish 3306:3306 mysql:8-oracle | ||
**Use** the following *properties* for **Spring** in the "*application.properties*" file: | ||
|
||
``` | ||
spring.datasource.url=jdbc:mysql://localhost:3306/dev-todos | ||
spring.datasource.username=dev-user | ||
spring.datasource.password=dev-pass | ||
``` | ||
|
||
**Run** the "*TodosApplication*" class with this *command*: | ||
|
||
>mvn spring-boot:run | ||
Go to this *URL* to **use** the *application*: | ||
|
||
>http://localhost:8080/todos | ||
### Monitoring | ||
|
||
**Connect** to the MySQL **DB** at the following *URL*: | ||
|
||
>jdbc:mysql://localhost:3306/dev-todos | ||
... with these **credentials**: | ||
|
||
>dev-user:dev-pass | ||
<hr/> | ||
|
||
## Production | ||
|
||
The *application* can be **deployed** as follows: | ||
|
||
|
||
### Usage | ||
|
||
**Run** the following *command* for Docker **Compose**: | ||
|
||
>docker-compose up | ||
Go to this *URL* to **use** the *application*: | ||
|
||
>http://localhost:6969/todos | ||
**Stop** the following *command* for Docker **Compose**: | ||
|
||
>docker-compose down | ||
### Monitoring | ||
|
||
**Connect** to the MySQL **DB** at the following *URL*: | ||
|
||
>jdbc:mysql://localhost:4242/todos-db | ||
... with these **credentials**: | ||
|
||
>root:p4$$w0rd | ||
<hr/> | ||
|
||
**Thank** you for *using* it! :D | ||
|
||
<hr/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
version: '3.9' | ||
|
||
services: | ||
|
||
data: | ||
|
||
image: mysql:8-oracle | ||
container_name: 'todos-data' | ||
|
||
restart: unless-stopped | ||
|
||
env_file: ./.env | ||
ports: | ||
- $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT | ||
|
||
environment: | ||
- MYSQL_ROOT_PASSWORD=$MYSQLDB_ROOT_PASSWORD | ||
- MYSQL_DATABASE=$MYSQLDB_DATABASE | ||
|
||
volumes: | ||
- db:/var/lib/mysql | ||
|
||
app: | ||
|
||
depends_on: | ||
- data | ||
|
||
build: ./todos-app | ||
|
||
image: 'todos-app:1.0.0' | ||
container_name: 'todos-app' | ||
|
||
restart: on-failure | ||
|
||
env_file: ./.env | ||
ports: | ||
- $SPRING_LOCAL_PORT:$SPRING_DOCKER_PORT | ||
|
||
environment: | ||
SPRING_APPLICATION_JSON: '{ | ||
"spring.datasource.url" : "jdbc:mysql://data:$MYSQLDB_DOCKER_PORT/$MYSQLDB_DATABASE", | ||
"spring.datasource.username" : "$MYSQLDB_USER", | ||
"spring.datasource.password" : "$MYSQLDB_ROOT_PASSWORD", | ||
"spring.jpa.hibernate.ddl-auto" : "update", | ||
"spring.jpa.properties.hibernate.dialect" : "org.hibernate.dialect.MySQLDialect" | ||
}' | ||
|
||
stdin_open: true | ||
tty: true | ||
|
||
proxy: | ||
|
||
depends_on: | ||
- app | ||
|
||
image: nginx:1.24-alpine | ||
container_name: 'todos-proxy' | ||
|
||
restart: always | ||
|
||
env_file: ./.env | ||
ports: | ||
- $NGINX_LOCAL_PORT:$NGINX_DOCKER_PORT | ||
|
||
volumes: | ||
- ./nginx.conf:/etc/nginx/nginx.conf:ro | ||
|
||
volumes: | ||
db: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
events {} | ||
|
||
http { | ||
|
||
server { | ||
|
||
listen 80; | ||
|
||
location / { | ||
proxy_pass http://app:8080; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Ignore all files in the root directory | ||
* | ||
# Include the src directory | ||
!src/ | ||
# Include the pom.xml file | ||
!pom.xml | ||
# Exclude the target directory and its contents | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
|
||
target/ | ||
|
||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
!**/src/test/**/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
# Cache the Dependencies | ||
|
||
FROM maven:3.9.1-eclipse-temurin-17-alpine AS builder | ||
|
||
WORKDIR /todos-app | ||
COPY pom.xml . | ||
|
||
RUN mvn dependency:go-offline | ||
|
||
# Package the Application | ||
|
||
COPY src/ ./src/ | ||
RUN mvn package -DskipTests | ||
|
||
# Create a Slim Image | ||
|
||
FROM eclipse-temurin:17-jre-alpine AS runner | ||
|
||
LABEL version="1.0.0" | ||
LABEL author="Ph4nToM" | ||
LABEL maintainer="subhatav@gmail.com" | ||
|
||
ENV SPRING_PROFILES_ACTIVE=production | ||
COPY --from=builder /todos-app/target/todos-app-1.0.0-SNAPSHOT.jar app.jar | ||
|
||
ENTRYPOINT ["java", "-jar", "/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.