Skip to content

Commit 645e13e

Browse files
committed
spring boot project
0 parents  commit 645e13e

File tree

56 files changed

+2247
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2247
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM openjdk:17
2+
WORKDIR /
3+
ADD target/spring-boot-thymeleaf-crud-db-project-0.0.1-SNAPSHOT.jar /
4+
EXPOSE 8080
5+
ENTRYPOINT ["java", "-jar", "/spring-boot-thymeleaf-crud-db-project-0.0.1-SNAPSHOT.jar"]

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# SpringBoot Thymeleaf with CUDR Database Concept.
2+
3+
<br>
4+
5+
## Overview
6+
The project is about the employee's table so it can display employees, add new employee, updates employee info and delete employee.
7+
8+
<br>
9+
10+
## Usages
11+
- SpringBoot
12+
- SpringJPA
13+
- Thymeleaf
14+
- MySQL
15+
16+
## Architecture of the Project
17+
18+
### 1- src folders
19+
- Controllers folder
20+
- Entities folder
21+
- DAO folder
22+
- Services folder
23+
24+
### 2-Maven pom.xml
25+
<br>
26+
27+
```
28+
<dependencies>
29+
30+
<!-- thymeleaf engin for html -->
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
34+
</dependency>
35+
36+
<!-- spring mvc includs RES support -->
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-web</artifactId>
40+
</dependency>
41+
42+
<!-- dev tool for reload server automatic when change code -->
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-devtools</artifactId>
46+
<scope>runtime</scope>
47+
<optional>true</optional>
48+
</dependency>
49+
50+
<!-- mysql deriver -->
51+
<dependency>
52+
<groupId>mysql</groupId>
53+
<artifactId>mysql-connector-java</artifactId>
54+
<scope>runtime</scope>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-starter-test</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-data-jpa</artifactId>
66+
</dependency>
67+
68+
<!-- Hibernate -->
69+
<dependency>
70+
<groupId>org.hibernate</groupId>
71+
<artifactId>hibernate-core</artifactId>
72+
<version>${hibernate.version}</version>
73+
</dependency>
74+
75+
</dependencies>
76+
```
77+
<br>
78+
79+
### 3-Application.properties.yml
80+
81+
```
82+
server.port=8082
83+
spring.datasource.url = jdbc:mysql://localhost:3306/employee-directory?useSSL=false&serverTimezone=UTC
84+
spring.datasource.username=springemployee
85+
spring.datasource.password= springemployee
86+
87+
```
88+
89+
## Let's Start :mechanical_arm:
90+
### • Display Empoyees Table
91+
<br>
92+
<img width="1674" alt="display-employee" src="https://user-images.githubusercontent.com/67427643/124305147-5d68ce80-db6d-11eb-8f44-e27b23c1645c.png">
93+
94+
95+
96+
### • Add new Employee
97+
<br>
98+
<img width="1673" alt="add-employee" src="https://user-images.githubusercontent.com/67427643/124305371-ade02c00-db6d-11eb-866e-bb572312e91e.png">
99+
<img width="1654" alt="add-employee" src="https://user-images.githubusercontent.com/67427643/124305516-e08a2480-db6d-11eb-8cff-08247c8a66fa.png">
100+
101+
102+
103+
### • Update Empoyee:
104+
<br>
105+
<img width="1665" alt="update-employee" src="https://user-images.githubusercontent.com/67427643/124305561-f0a20400-db6d-11eb-91d8-e4c0c94f9a60.png">
106+
<img width="1659" alt="update-employee" src="https://user-images.githubusercontent.com/67427643/124305710-1fb87580-db6e-11eb-9935-306d2030080e.png">
107+
108+
109+
110+
### • Delete Employee:
111+
<br>
112+
<img width="1646" alt="delete-employee" src="https://user-images.githubusercontent.com/67427643/124306008-863d9380-db6e-11eb-9502-0cf65233b8a2.png">
113+
<img width="1671" alt="delete-employee" src="https://user-images.githubusercontent.com/67427643/124306030-8b024780-db6e-11eb-8a2c-02ef02fc6e33.png">
114+
115+
---
116+
117+
### Good Luck <img src="https://media.giphy.com/media/hvRJCLFzcasrR4ia7z/giphy.gif" width="30px">
118+
# project-deploy

deployment/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
varabiles.tf

deployment/bastion-sg.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resource "alicloud_security_group" "bastion-sg" {
2+
name = "bastion-sg"
3+
description = "bastion security group"
4+
vpc_id = alicloud_vpc.vpc.id
5+
}
6+
resource "alicloud_security_group_rule" "allow-bastion-to-ssh" {
7+
type = "ingress"
8+
ip_protocol = "tcp"
9+
policy = "accept"
10+
port_range = "22/22"
11+
priority = 1
12+
security_group_id = alicloud_security_group.bastion-sg.id
13+
cidr_ip = "0.0.0.0/0"
14+
}

deployment/bastion.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource "alicloud_instance" "bastion-instance" {
2+
availability_zone = data.alicloud_zones.default.zones.0.id
3+
instance_name = "bastion"
4+
instance_type = "ecs.g6.large"
5+
image_id = "ubuntu_24_04_x64_20G_alibase_20240812.vhd"
6+
security_groups = [alicloud_security_group.bastion-sg.id]
7+
internet_charge_type = "PayByTraffic"
8+
instance_charge_type = "PostPaid"
9+
system_disk_category = "cloud_essd"
10+
vswitch_id = alicloud_vswitch.public.id
11+
key_name = alicloud_ecs_key_pair.key.key_pair_name
12+
internet_max_bandwidth_out = 10
13+
}
14+
15+
output "bastion_public_ip" {
16+
value = alicloud_instance.bastion-instance.public_ip
17+
}

deployment/employee-sg.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "alicloud_security_group" "employee-sg" {
2+
description = "employee security group"
3+
vpc_id = alicloud_vpc.vpc.id
4+
}
5+
resource "alicloud_security_group_rule" "allow-employee-to-ssh" {
6+
type = "ingress"
7+
ip_protocol = "tcp"
8+
policy = "accept"
9+
port_range = "22/22"
10+
priority = 1
11+
security_group_id = alicloud_security_group.employee-sg.id
12+
source_security_group_id = alicloud_security_group.bastion-sg.id
13+
}

deployment/employee.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "alicloud_instance" "employee-instance" {
2+
count = 2
3+
availability_zone = data.alicloud_zones.default.zones.0.id
4+
instance_name = "web-${count.index}"
5+
instance_type = "ecs.g6.large"
6+
image_id = "ubuntu_24_04_x64_20G_alibase_20240812.vhd"
7+
security_groups = [alicloud_security_group.employee-sg.id]
8+
internet_charge_type = "PayByTraffic"
9+
instance_charge_type = "PostPaid"
10+
system_disk_category = "cloud_essd"
11+
vswitch_id = alicloud_vswitch.private.id
12+
key_name = alicloud_ecs_key_pair.key.key_pair_name
13+
internet_max_bandwidth_out = 0
14+
user_data = base64encode(templatefile("employee.tpl", {
15+
redis_host = alicloud_instance.redis-instance.private_ip,
16+
db_host = alicloud_instance.db-instance.private_ip,
17+
db_user = var.db_user,
18+
db_password = var.db_password,
19+
db_name = var.db_name
20+
}))
21+
22+
}
23+
24+
output "employee_private_ips" {
25+
value = alicloud_instance.web-instance.*.private_ip
26+
}

deployment/employee.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
sudo apt-get update -yy
4+
sudo apt-get install -yy git curl
5+
curl -fsSL https://get.docker.com -o get-docker.sh
6+
sudo sh ./get-docker.sh
7+
8+
docker run -d \
9+
-p 8008:8080 \
10+
--name employee_app \
11+
-e REDIS_HOST="${redis_host}" \
12+
-e DB_HOST="${db_host}" \
13+
-e DB_USER="${db_user}" \
14+
-e DB_PASSWORD="${db_password}" \
15+
-e DB_NAME="${db_name}" \
16+
sarakalhussain/devops:latest

deployment/key.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "alicloud_ecs_key_pair" "key" {
2+
key_pair_name = "key"
3+
key_file = "key.pem"
4+
}

0 commit comments

Comments
 (0)