From c9746bb6da8aea0e66e02f78139205494210860f Mon Sep 17 00:00:00 2001 From: ybandala Date: Tue, 11 Feb 2025 00:24:23 -0600 Subject: [PATCH] Added resources for the CICD setup --- .DS_Store | Bin 0 -> 6148 bytes .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ Dockerfile | 13 +++++++++++++ k8s/base/deployment.yaml | 35 +++++++++++++++++++++++++++++++++++ k8s/base/service.yaml | 11 +++++++++++ k8s/deployment.yml | 0 6 files changed, 87 insertions(+) create mode 100644 .DS_Store create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile create mode 100644 k8s/base/deployment.yaml create mode 100644 k8s/base/service.yaml create mode 100644 k8s/deployment.yml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a72eb1cf5ce38681e1cf1caf2962987190f7aee9 GIT binary patch literal 6148 zcmeH~Jr2S!425mzfW*>~F$)J^V~h}-fD0h#1`-2e&(V4QSt!h?LeG-@#ZIlZZ)j=} z(cN>{i1Z?|fE#6PVPuMYE?3#gV|ZL{=llI;CAV493h-V=`?*a}0V+TRr~nn90uxdo z5AwxwLeIoUp#oH38VcC=p}>tb*@FJ*K=2U&>`->Y+Gh!{SOKib7DNT6(F#VZ`WRw$ zZwE_WSCcIm?V>q+Xx>?Eih*ggixwm>tquk%Km|q$%p>pZ{6E0I&Htkorc{6m{FwsU z?T`B%UMkPlkJq#MDXX?_aL_MDc>4)JVn^``?uPwh3$P|z5EU4I1Y8CND)3VUUI*k6 ALjV8( literal 0 HcmV?d00001 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..42b9409d7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: Build and Deploy +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: ./mvnw package -B + + - name: Build Docker Image + run: docker build -t petclinic:${{ github.sha }} . + + - name: Test + run: ./mvnw test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b8515f0b5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM eclipse-temurin:17-jdk-jammy as builder +WORKDIR /app +COPY .mvn/ .mvn +COPY mvnw pom.xml ./ +RUN ./mvnw dependency:go-offline +COPY src ./src +RUN ./mvnw package -DskipTests + +FROM eclipse-temurin:17-jre-jammy +WORKDIR /app +COPY --from=builder /app/target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/k8s/base/deployment.yaml b/k8s/base/deployment.yaml new file mode 100644 index 000000000..06b0bb99b --- /dev/null +++ b/k8s/base/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: petclinic +spec: + replicas: 1 + selector: + matchLabels: + app: petclinic + template: + metadata: + labels: + app: petclinic + spec: + containers: + - name: petclinic + image: petclinic:latest + ports: + - containerPort: 8080 + resources: + requests: + memory: "512Mi" + cpu: "250m" + limits: + memory: "1Gi" + cpu: "500m" + readinessProbe: + httpGet: + path: /actuator/health + port: 8080 + initialDelaySeconds: 30 + periodSeconds: 10 + - name: petclinic + image: petclinic:latest + imagePullPolicy: IfNotPresent \ No newline at end of file diff --git a/k8s/base/service.yaml b/k8s/base/service.yaml new file mode 100644 index 000000000..b0a5ebd8a --- /dev/null +++ b/k8s/base/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: petclinic +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 8080 + selector: + app: petclinic \ No newline at end of file diff --git a/k8s/deployment.yml b/k8s/deployment.yml new file mode 100644 index 000000000..e69de29bb