diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a15fe1a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM maven:3.9.6-eclipse-temurin-17 AS build +WORKDIR /app +COPY . . +RUN mvn package -DskipTests + +FROM eclipse-temurin:17-jre-noble as package +WORKDIR /app +COPY --from=build /app/target/sysfoo-*.jar ./sysfoo.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "sysfoo.jar"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..10091b5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,73 @@ +pipeline { + agent none + stages { + stage('build') { + agent { + docker { + image 'maven:3.8.8-eclipse-temurin-21-alpine' + } + + } + steps { + echo 'compile maven app' + sh '''ls +echo "WORKSPACE = $WORKSPACE"''' + sh 'mvn clean install -Dmaven.repo.local=$WORKSPACE/.m2/repository' + } + } + + stage('test') { + agent { + docker { + image 'maven:3.8.8-eclipse-temurin-21-alpine' + } + + } + steps { + echo 'test maven app' + sh 'mvn clean test -Dmaven.repo.local=$WORKSPACE/.m2/repository' + echo 'my custom message' + } + } + + stage('package') { + when { branch 'main'} + parallel { + stage('package') { + agent { + docker { + image 'maven:3.8.8-eclipse-temurin-21-alpine' + } + + } + steps { + echo 'package maven app' + sh 'mvn package -DskipTests -Dmaven.repo.local=$WORKSPACE/.m2/repository' + archiveArtifacts '**/target/*.jar' + } + } + + stage('Docker B&D') { + agent any + steps { + script { + docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') { + def commitHash = env.GIT_COMMIT.take(7) + def dockerImage = docker.build("pprahas/sysfoo:${commitHash}", "./") + dockerImage.push() + dockerImage.push("latest") + dockerImage.push("dev") + } + } + + } + } + + } + } + + } + tools { + maven 'Maven 3.8.8' + } +} diff --git a/README.md b/README.md index 301005c..6ae4ea5 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,20 @@ The Sysfoo application is designed as a learning tool to demonstrate various asp This application is ideal for individuals learning about Spring Boot, RESTful services, and simple frontend interactions with JavaScript. This is also useful for anyone who would like to implement Devops Practices with this App. +![Sysfoo Architecture](./docs/h2.jpg) + +As part of devops learning you could take this app and + + * Containerize it by writing a Dockerfile + * Setup a dev environment with Docker Compose + * Build a CI Pipeline with Jenkins, Docker, Git + * Deploy using Kubernetes + * Setup Automated Devployments with ArgoCD + * Setup DevSecOps workflows + * Deploy it on Cloud and automate that with Terraform + +These are just a few ideas you could try and then build so much on top of this. + ## Building the Application To build and run the Sysfoo application, follow these steps: @@ -78,7 +92,7 @@ You may have to replace `localhost` with the actual hostname or IP address based Following is how the front page looks like -![Sysfoo Web](./sysfoo-web.png) +![Sysfoo Web](./docs/sysfoo-web.png) @@ -86,6 +100,9 @@ Following is how the front page looks like This application usesa embded, in memory database called H2 by default. To use PostgreSQL as the database for the Sysfoo application, you need to configure both the application properties and set up the environment appropriately. Here’s how you can switch from the default H2 database to PostgreSQL. +![Sysfoo Architecture](./docs/not_h2.jpg) +![Sysfoo Architecture with Postgres](./docs/postgres.jpg) + ### Prerequisites - PostgreSQL installed on your development machine or access to a PostgreSQL server. diff --git a/docs/h2.jpg b/docs/h2.jpg new file mode 100644 index 0000000..654ad0d Binary files /dev/null and b/docs/h2.jpg differ diff --git a/docs/not_h2.jpg b/docs/not_h2.jpg new file mode 100644 index 0000000..3a2bdb9 Binary files /dev/null and b/docs/not_h2.jpg differ diff --git a/docs/postgres.jpg b/docs/postgres.jpg new file mode 100644 index 0000000..05bbfa1 Binary files /dev/null and b/docs/postgres.jpg differ diff --git a/sysfoo-web.png b/docs/sysfoo-web.png similarity index 100% rename from sysfoo-web.png rename to docs/sysfoo-web.png diff --git a/test.md b/test.md new file mode 100644 index 0000000..d8ce320 --- /dev/null +++ b/test.md @@ -0,0 +1 @@ +dded change 1 after protection rule