mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
Merge 9c55ed36c1
into 2daa3993ee
This commit is contained in:
commit
27ead41283
3 changed files with 72 additions and 0 deletions
34
Dockerfile
Normal file
34
Dockerfile
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#stage 1
|
||||||
|
# Use a base image with OpenJDK
|
||||||
|
FROM openjdk:17-jdk-slim as build
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install Maven
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y maven && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy the project files into the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Package the application using Maven
|
||||||
|
RUN ./mvnw package
|
||||||
|
|
||||||
|
#stage 2
|
||||||
|
# Stage 2: Create a Distroless image
|
||||||
|
FROM gcr.io/distroless/java17
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the packaged JAR from the build stage
|
||||||
|
COPY --from=build /app/target/spring-petclinic-3.3.0-SNAPSHOT.jar app.jar
|
||||||
|
|
||||||
|
#Expose port
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
#cmd command
|
||||||
|
CMD ["app.jar"]
|
21
k8s/deployment.yaml
Normal file
21
k8s/deployment.yaml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: petclinic
|
||||||
|
labels:
|
||||||
|
app: petclinic
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: petclinic
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: petclinic
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: petclinic-container
|
||||||
|
image: nginx:1.14.2
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
17
k8s/service.yaml
Normal file
17
k8s/service.yaml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: petclinic-service
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
selector:
|
||||||
|
app: petclinic
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
# 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
|
Loading…
Reference in a new issue