Skip to content

Commit 1f7d39a

Browse files
committed
Initial commit
0 parents  commit 1f7d39a

Some content is hidden

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

44 files changed

+2340
-0
lines changed

.github/workflows/cicd.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: CICD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: self-hosted
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
cache: maven
20+
- name: Build with Maven
21+
run: mvn package --file pom.xml
22+
23+
- uses: actions/upload-artifact@v4
24+
with:
25+
name: Boardgame
26+
path: target/*.jar
27+
28+
- name: Trivy FS Scan
29+
run: |
30+
trivy fs --format table -o trivy-fs-report.html .
31+
32+
- name: SonarQube Scan
33+
uses: sonarsource/sonarqube-scan-action@master
34+
env:
35+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
36+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
37+
38+
- name: Install jq
39+
run: sudo apt-get update && sudo apt-get install -y jq
40+
41+
# Check the Quality Gate status.
42+
- name: SonarQube Quality Gate check
43+
id: sonarqube-quality-gate-check
44+
uses: sonarsource/sonarqube-quality-gate-action@master
45+
# Force to fail step after specific time.
46+
timeout-minutes: 5
47+
env:
48+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
49+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@v3
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Build Docker Image
58+
run: |
59+
docker build -t adijaiswal/boardgame:latest .
60+
61+
- name: Trivy Image Scan
62+
run: |
63+
trivy image --format table -o trivy-image-report.html adijaiswal/board:latest
64+
65+
- name: Login to Docker Hub
66+
uses: docker/login-action@v3
67+
with:
68+
username: ${{ secrets.DOCKERHUB_USERNAME }}
69+
password: ${{ secrets.DOCKERHUB_TOKEN }}
70+
71+
- name: Push Docker Image
72+
run: |
73+
docker push adijaiswal/boardgame:latest
74+
75+
- name: Kubectl Action
76+
uses: tale/kubectl-action@v1
77+
with:
78+
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
79+
- run: |
80+
kubectl apply -f deployment-service.yaml -n webapps
81+
kubectl get svc -n webapps
82+
83+

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

.mvn/wrapper/maven-wrapper.jar

57.4 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM adoptopenjdk/openjdk11
2+
3+
EXPOSE 8080
4+
5+
ENV APP_HOME /usr/src/app
6+
7+
COPY target/*.jar $APP_HOME/app.jar
8+
9+
WORKDIR $APP_HOME
10+
11+
CMD ["java", "-jar", "app.jar"]

Jenkinsfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
pipeline {
2+
agent any
3+
tools {
4+
jdk 'jdk17'
5+
maven 'maven3'
6+
}
7+
8+
stages {
9+
stage('Compile') {
10+
steps {
11+
sh 'mvn compile'
12+
}
13+
}
14+
15+
stage('Test') {
16+
steps {
17+
sh 'mvn test'
18+
}
19+
}
20+
21+
stage('Build') {
22+
steps {
23+
sh 'mvn package'
24+
}
25+
}
26+
}
27+
}

Jenkinsfile123

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pipeline {
2+
agent {label 'slave-1'}
3+
4+
tools {
5+
jdk 'jdk17'
6+
maven 'maven3'
7+
}
8+
9+
stages {
10+
stage('Compile') {
11+
steps {
12+
sh 'mvn compile'
13+
}
14+
}
15+
16+
stage('Test') {
17+
steps {
18+
sh 'mvn test'
19+
}
20+
}
21+
22+
stage('Build') {
23+
steps {
24+
sh 'mvn package'
25+
}
26+
}
27+
}
28+
}

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# BoardgameListingWebApp
2+
3+
## Description
4+
5+
**Board Game Database Full-Stack Web Application.**
6+
This web application displays lists of board games and their reviews. While anyone can view the board game lists and reviews, they are required to log in to add/ edit the board games and their reviews. The 'users' have the authority to add board games to the list and add reviews, and the 'managers' have the authority to edit/ delete the reviews on top of the authorities of users.
7+
8+
## Technologies
9+
10+
- Java
11+
- Spring Boot
12+
- Amazon Web Services(AWS) EC2
13+
- Thymeleaf
14+
- Thymeleaf Fragments
15+
- HTML5
16+
- CSS
17+
- JavaScript
18+
- Spring MVC
19+
- JDBC
20+
- H2 Database Engine (In-memory)
21+
- JUnit test framework
22+
- Spring Security
23+
- Twitter Bootstrap
24+
- Maven
25+
26+
## Features
27+
28+
- Full-Stack Application
29+
- UI components created with Thymeleaf and styled with Twitter Bootstrap
30+
- Authentication and authorization using Spring Security
31+
- Authentication by allowing the users to authenticate with a username and password
32+
- Authorization by granting different permissions based on the roles (non-members, users, and managers)
33+
- Different roles (non-members, users, and managers) with varying levels of permissions
34+
- Non-members only can see the boardgame lists and reviews
35+
- Users can add board games and write reviews
36+
- Managers can edit and delete the reviews
37+
- Deployed the application on AWS EC2
38+
- JUnit test framework for unit testing
39+
- Spring MVC best practices to segregate views, controllers, and database packages
40+
- JDBC for database connectivity and interaction
41+
- CRUD (Create, Read, Update, Delete) operations for managing data in the database
42+
- Schema.sql file to customize the schema and input initial data
43+
- Thymeleaf Fragments to reduce redundancy of repeating HTML elements (head, footer, navigation)
44+
45+
## How to Run
46+
47+
1. Clone the repository
48+
2. Open the project in your IDE of choice
49+
3. Run the application
50+
4. To use initial user data, use the following credentials.
51+
- username: bugs | password: bunny (user role)
52+
- username: daffy | password: duck (manager role)
53+
5. You can also sign-up as a new user and customize your role to play with the application! 😊

deployment-service.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: apps/v1
2+
kind: Deployment # Kubernetes resource kind we are creating
3+
metadata:
4+
name: boardgame-deployment
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: boardgame
9+
replicas: 2 # Number of replicas that will be created for this deployment
10+
template:
11+
metadata:
12+
labels:
13+
app: boardgame
14+
spec:
15+
containers:
16+
- name: boardgame
17+
image: adijaiswal/boardgame:latest # Image that will be used to containers in the cluster
18+
imagePullPolicy: Always
19+
ports:
20+
- containerPort: 8080 # The port that the container is running on in the cluster
21+
22+
23+
---
24+
25+
apiVersion: v1 # Kubernetes API version
26+
kind: Service # Kubernetes resource kind we are creating
27+
metadata: # Metadata of the resource kind we are creating
28+
name: boardgame-ssvc
29+
spec:
30+
selector:
31+
app: boardgame
32+
ports:
33+
- protocol: "TCP"
34+
port: 8080
35+
targetPort: 8080
36+
type: LoadBalancer # type of the service.

0 commit comments

Comments
 (0)