Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# setting the base image, will be creating the build image
FROM maven:3.8.8-eclipse-temurin-17 AS builder

# setting up the work directory
WORKDIR /app

# Copy the project files
COPY pom.xml .

# run the mvn dependencies
RUN mvn dependency:go-offline

# copy all the data to work directory
COPY . .

# running mvn clean at build time
RUN mvn clean package -DskipTests

# Use a lightweight JDK runtime for the final image
# using multiple from to build multi-stage image
FROM openjdk:17-jdk-slim

# setting the new work directory
WORKDIR /app

# Copy the built JAR from the builder stage
COPY --from=builder /app/target/*.jar app.jar

# exposing port 8080 where java app will run
EXPOSE 8080

# setting the entry point, to run the application when it comes live
ENTRYPOINT ["java", "-jar", "app.jar"]

21 changes: 21 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world-deployment
labels:
app: java-application
spec:
replicas: 3
selector:
matchLabels:
app: java-application
template:
metadata:
labels:
app: java-application
spec:
containers:
- name: java-application
image: abhiramikannan/javaimage:latest
ports:
- containerPort: 8080
17 changes: 17 additions & 0 deletions service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: java-application
ports:
- port: 8080
# By default and for convenience, the `targetPort` is set to
# the same value as the `port` field.
targetPort: 8080
# Optional field
# By default and for convenience, the Kubernetes control plane
# will allocate a port from a range (default: 30000-32767)
nodePort: 30007