-
Notifications
You must be signed in to change notification settings - Fork 356
Added Jenkinsfile, Nginx Setup, Updated README, and Docker Compose Configuration #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: DevOps
Are you sure you want to change the base?
Changes from all commits
7680383
a966c85
13fb32f
56a16ac
2604c35
01ea966
bd95c5b
755e98a
e1e4e82
ddca7c4
37a9ece
462d418
fbfcf01
ddcb499
a01d1cc
b1f70de
b8ad79c
50e0392
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,31 @@ | ||
| #---------------------------------- | ||
| # Stage 1 | ||
| # Stage 1 - Build Environment | ||
| #---------------------------------- | ||
|
|
||
| # Import docker image with maven installed | ||
| FROM maven:3.8.3-openjdk-17 as builder | ||
| # Use Maven with OpenJDK 17 to compile the application | ||
| FROM maven:3.8.3-openjdk-17 AS builder | ||
|
|
||
| # Add maintainer, so that new user will understand who had written this Dockerfile | ||
| MAINTAINER Madhup Pandey<madhuppandey2908@gmail.com> | ||
| # Set the working directory in the container | ||
| WORKDIR /app | ||
|
|
||
| # Add labels to the image to filter out if we have multiple application running | ||
| LABEL app=bankapp | ||
| # Copy all project files to the working directory | ||
| COPY . /app | ||
|
|
||
| # Set working directory | ||
| WORKDIR /src | ||
|
|
||
| # Copy source code from local to container | ||
| COPY . /src | ||
|
|
||
| # Build application and skip test cases | ||
| # Build the project and skip tests for a faster build process | ||
| RUN mvn clean install -DskipTests=true | ||
|
|
||
| #-------------------------------------- | ||
| # Stage 2 | ||
| # Stage 2 - Production Environment | ||
| #-------------------------------------- | ||
|
|
||
| # Import small size java image | ||
| FROM openjdk:17-alpine as deployer | ||
| # Use a lightweight OpenJDK 17 image to run the application | ||
| FROM openjdk:17-jdk-alpine | ||
|
|
||
| # Copy build from stage 1 (builder) | ||
| COPY --from=builder /src/target/*.jar /src/target/bankapp.jar | ||
| # Copy the application JAR from the builder stage to the target location | ||
| COPY --from=builder /app/target/*.jar /app/target/bankapp.jar | ||
|
|
||
| # Expose application port | ||
| EXPOSE 8080 | ||
| # Expose the application port (updated to 8000) | ||
| EXPOSE 8000 | ||
|
|
||
| # Start the application | ||
| ENTRYPOINT ["java", "-jar", "/src/target/bankapp.jar"] | ||
| # Define the command to run the application | ||
| ENTRYPOINT ["java", "-jar", "/app/target/bankapp.jar"] | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||||||
| @Library('Shared')_ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| pipeline{ | ||||||||||||||||||||||||||||||||
| agent {label 'dev-server'} | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| stages{ | ||||||||||||||||||||||||||||||||
| stage("Code"){ | ||||||||||||||||||||||||||||||||
| steps{ | ||||||||||||||||||||||||||||||||
| clone("https://github.com/Amitabh-DevOps/banking-app-project.git","dev") | ||||||||||||||||||||||||||||||||
| echo "Code clonning done." | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Hardcoded repository URL The repository URL should not be hardcoded in the pipeline. Consider:
- clone("https://github.com/Amitabh-DevOps/banking-app-project.git","dev")
+ clone(env.REPO_URL, "dev")
|
||||||||||||||||||||||||||||||||
| stage("Build"){ | ||||||||||||||||||||||||||||||||
| steps{ | ||||||||||||||||||||||||||||||||
| dockerbuild("bankapp-mini","latest") | ||||||||||||||||||||||||||||||||
| echo "Code build bhi hogaya." | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve build stage with version control and documentation The build stage could be enhanced:
- dockerbuild("bankapp-mini","latest")
- echo "Code build bhi hogaya."
+ def version = env.BUILD_NUMBER
+ dockerbuild("bankapp-mini", version)
+ echo "Successfully built Docker image bankapp-mini:${version}"📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| stage("Push to DockerHub"){ | ||||||||||||||||||||||||||||||||
| steps{ | ||||||||||||||||||||||||||||||||
| dockerpush("dockerHub","bankapp-mini","latest") | ||||||||||||||||||||||||||||||||
| echo "Push to dockerHub is also done." | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Security and versioning improvements needed for Docker push The Docker push stage needs enhancements:
- dockerpush("dockerHub","bankapp-mini","latest")
- echo "Push to dockerHub is also done."
+ withCredentials([usernamePassword(credentialsId: 'docker-hub-creds', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
+ def version = env.BUILD_NUMBER
+ dockerpush(env.DOCKER_USER, "bankapp-mini", version)
+ echo "Successfully pushed bankapp-mini:${version} to DockerHub"
+ }📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
| stage("Deplying"){ | ||||||||||||||||||||||||||||||||
| steps{ | ||||||||||||||||||||||||||||||||
| deploy() | ||||||||||||||||||||||||||||||||
| echo "Deployment bhi done." | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance deployment stage with environment and rollback support The deployment stage lacks:
- deploy()
- echo "Deployment bhi done."
+ script {
+ def version = env.BUILD_NUMBER
+ def environment = env.DEPLOY_ENV ?: 'development'
+ deploy(environment: environment, version: version)
+ echo "Successfully deployed bankapp-mini:${version} to ${environment}"
+ }
|
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance production stage security and reliability
Several improvements can be made to the production stage:
Apply these security and reliability improvements: