From bff52a78f99050f31d10e546fc28ea4c428beae9 Mon Sep 17 00:00:00 2001 From: Prithviraj Ghosh <64319848+prithvirajpro@users.noreply.github.com> Date: Wed, 15 Jan 2025 06:28:59 +0530 Subject: [PATCH] Added Dockerfile and 2 yamls --- Dockerfile | 14 ++++++++++++++ deployment.yaml | 19 +++++++++++++++++++ service.yaml | 12 ++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 Dockerfile create mode 100644 deployment.yaml create mode 100644 service.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..87fb574d3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use a base Java image +FROM openjdk:17-jdk-slim + +# Set the working directory +WORKDIR /app + +# Copy the JAR file built by Maven +COPY target/*.jar app.jar + +# Expose the application port +EXPOSE 8080 + +# Command to run the application +ENTRYPOINT ["java", "-jar", "app.jar"] diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 000000000..078eae343 --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: spring-petclinic-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: spring-petclinic + template: + metadata: + labels: + app: spring-petclinic + spec: + containers: + - name: spring-petclinic + image: prithvirajpro/spring-petclinic + ports: + - containerPort: 8080 diff --git a/service.yaml b/service.yaml new file mode 100644 index 000000000..33d936ab2 --- /dev/null +++ b/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: spring-petclinic-service +spec: + selector: + app: spring-petclinic + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + type: NodePort