Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
04b0d24
Dockerfile
sunil3gs98 Aug 7, 2024
3115f99
Update README.md
sunil3gs98 Aug 9, 2024
5846fb6
docker-compose.yml
sunil3gs98 Aug 9, 2024
b0f480a
Update application.properties
sunil3gs98 Aug 9, 2024
acf892f
Update pom.xml
sunil3gs98 Aug 9, 2024
3d79133
Update docker-compose.yml
sunil3gs98 Aug 16, 2024
d66e95e
Create app.yml
sunil3gs98 Aug 16, 2024
a660603
Delete k8-deployments/app.yml
sunil3gs98 Aug 16, 2024
e976e40
Create app.yml
sunil3gs98 Aug 16, 2024
7c00e41
Add files via upload
sunil3gs98 Aug 16, 2024
fcf70e4
Delete app.yml
sunil3gs98 Aug 16, 2024
b3b015f
Update app-deployment.yaml
sunil3gs98 Aug 16, 2024
f2b6b43
Update app-deployment.yaml
sunil3gs98 Aug 16, 2024
8001c76
Update app-service.yaml
sunil3gs98 Aug 16, 2024
b10ad8d
Update db-deployment.yaml
sunil3gs98 Aug 16, 2024
6f98b73
Update db-pvc.yaml
sunil3gs98 Aug 16, 2024
24248c0
Update db-service.yaml
sunil3gs98 Aug 16, 2024
a868145
Update docker-compose.yml
sunil3gs98 Aug 26, 2024
dcac5e9
Update app-service.yaml
sunil3gs98 Aug 30, 2024
910ab5b
Update db-service.yaml
sunil3gs98 Aug 30, 2024
fce6c37
Update app-deployment.yaml
sunil3gs98 Aug 31, 2024
5854eda
Create php-admin-service.yaml
sunil3gs98 Sep 9, 2024
ccd5c82
Create php-admin.yaml
sunil3gs98 Sep 9, 2024
cc285fd
Update php-admin.yaml
sunil3gs98 Sep 15, 2024
ca309f5
Update pom.xml
sunil3gs98 Sep 17, 2024
2dff3f7
Update application.properties
sunil3gs98 Sep 17, 2024
ab600da
Update app-service.yaml
sunil3gs98 Sep 17, 2024
aae498a
Update docker-compose.yml
sunil3gs98 Sep 17, 2024
b0d74c4
image update from v1.0.0 -v1.1.0
sunil3gs98 Sep 17, 2024
2748e12
Update app-deployment.yaml
sunil3gs98 Sep 28, 2024
f996181
Update app-service.yaml
sunil3gs98 Sep 28, 2024
8ca5ddc
Update db-deployment.yaml
sunil3gs98 Sep 28, 2024
b80a7e2
Update db-service.yaml
sunil3gs98 Sep 28, 2024
d92a7d5
Update app-deployment.yaml
sunil3gs98 Sep 28, 2024
6d83c67
Update db-deployment.yaml
sunil3gs98 Sep 28, 2024
a2916c4
Update app-deployment.yaml
sunil3gs98 May 2, 2025
cf5b561
Update app-deployment.yaml
sunil3gs98 May 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Stage 1: Build the application
FROM maven:3.8.1-openjdk-11 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean install -Dmaven.test.skip=true

# Stage 2: Run the application
FROM openjdk:11-jre-slim
WORKDIR /app
COPY --from=build /app/target/*.jar /app/app.jar
CMD ["java", "-jar", "app.jar"]
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Secret Santa Generator Application :santa:

A __secret santa generator web application__ built using __Spring Boot technologies__, __Thymeleaf views__, __JPA__, __H2 Database__, and more. The project features Spring Model, View, and Controller (MVC) architecture and Service and Repository layers.
A __secret santa generator web application__ built using __Spring Boot technologies__, __Thymeleaf views__, __JPA__, __MYSQL Database__, and more. The project features Spring Model, View, and Controller (MVC) architecture and Service and Repository layers.

This project is based on the popular Christmas game __Secret Santa__ where friends draw names from a hat to decide who they are required to give a present to. This project allows users to add names, and the project randomly generates secret santa matches (it isn't as simple as creating random pairs). There are different solutions to the "Secret Santa problem" as the problem essentially creates a directed graph.

Expand Down Expand Up @@ -43,13 +43,7 @@ Or you can run it from Maven directly using the Spring Boot Maven plugin.
```

## Database Configuration
This project uses an in-memory database (H2). If you would like to work on the project, enable the `http://localhost:8080/h2-console` via the property :

```spring.h2.console.enabled=true```

in __application.properties__.

The database url used is `jdbc:h2:mem:testdb`.
This project uses an MYSQL database
## About

This project was a personal project to learn more about Spring development, database management, and industry application architecture.
Expand All @@ -62,7 +56,7 @@ A small summary of the skills showcased during this project: :small_red_triangle
* Thymeleaf technology, syntax, usage, capabilities, more
* Client/Server data transfer
* JPA annotations and repository management
* H2 in-memory database management
* MYSQL database management
* Software/web application development processes
* MVC architecture along with DAO, model, service layers, and similar
* Accessibility, web design
Expand Down
38 changes: 38 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: '3.8'
services:
app:
image: sunil3gs98/secretesanta-generator:v1.1.0
ports:
- "8080:8080"
container_name: santa
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/santadb?autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=false
SPRING_DATASOURCE_USERNAME: admin
SPRING_DATASOURCE_PASSWORD: root
depends_on:
- db

db:
image: mysql:8.0.27
environment:
DATABASE_HOST: docker-mysql
DATABASE_POST: 3306
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: santadb
MYSQL_USER: admin
MYSQL_PASSWORD: root
volumes:
- db_data:/var/lib/mysql

phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
ports:
- "8081:80"
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: root
depends_on:
- db

volumes:
db_data:
31 changes: 31 additions & 0 deletions k8-deployments/app-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: santa-app
namespace: sunil3gs98
labels:
app: santa
spec:
replicas: 4
selector:
matchLabels:
app: santa
version: blue
template:
metadata:
labels:
app: santa
version: blue
spec:
containers:
- name: santa
image: sunil3gs98/secretesanta-generator:v1.1.0
ports:
- containerPort: 8080
env:
- name: SPRING_DATASOURCE_URL
value: "jdbc:mysql://santa-db-service:3306/santadb?autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=false"
- name: SPRING_DATASOURCE_USERNAME
value: "admin"
- name: SPRING_DATASOURCE_PASSWORD
value: "root"
16 changes: 16 additions & 0 deletions k8-deployments/app-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: santa-app-service
namespace: sunil3gs98
labels:
app: santa
spec:
selector:
app: santa
version: blue
ports:
- protocol: TCP
port: 8080
targetPort: 8080
type: LoadBalancer
40 changes: 40 additions & 0 deletions k8-deployments/db-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: santa-db
namespace: sunil3gs98
labels:
app: santa-db
spec:
replicas: 1
selector:
matchLabels:
app: santa-db
version: blue
template:
metadata:
labels:
app: santa-db
version: blue
spec:
containers:
- name: mysql
image: mysql:8.0.27
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "root"
- name: MYSQL_DATABASE
value: "santadb"
- name: MYSQL_USER
value: "admin"
- name: MYSQL_PASSWORD
value: "root"
volumeMounts:
- name: db-data
mountPath: /var/lib/mysql
volumes:
- name: db-data
persistentVolumeClaim:
claimName: db-pvc
13 changes: 13 additions & 0 deletions k8-deployments/db-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: db-pvc
namespace: sunil3gs98
labels:
app: santa-db
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
16 changes: 16 additions & 0 deletions k8-deployments/db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: santa-db-service
namespace: sunil3gs98
labels:
app: santa-db
spec:
selector:
app: santa-db
version: blue
ports:
- protocol: TCP
port: 3306
targetPort: 3306
type: LoadBalancer
13 changes: 13 additions & 0 deletions k8-deployments/php-admin-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: phpmyadmin
namespace: sunil3gs98
spec:
selector:
app: phpmyadmin
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer # or NodePort if you prefer
27 changes: 27 additions & 0 deletions k8-deployments/php-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: phpmyadmin
namespace: sunil3gs98
spec:
replicas: 1
selector:
matchLabels:
app: phpmyadmin
template:
metadata:
labels:
app: phpmyadmin
spec:
containers:
- name: phpmyadmin
image: phpmyadmin/phpmyadmin
ports:
- containerPort: 80
env:
- name: PMA_HOST
value: santa-db-service
- name: PMA_USER
value: admin
- name: PMA_PASSWORD
value: root
21 changes: 17 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.12</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -48,6 +52,15 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:testdb
# Datasource configuration
spring.datasource.url=jdbc:mysql://localhost:3306/santadb?autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username=admin
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.initialization-mode=always

# Actuator endpoint exposure configuration
management.endpoints.web.exposure.include=health,info,prometheus,auditevents,beans,caches,conditions,configprops,env,heapdump,loggers,metrics,mappings,threaddump,sessions
management.endpoint.prometheus.enabled=true

# JPA (Hibernate) configuration
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto=update