Skip to content

Instantly share code, notes, and snippets.

@trisberg
Last active June 20, 2023 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trisberg/03e2499cb530f7ce9eaf48abb8d1c435 to your computer and use it in GitHub Desktop.
Save trisberg/03e2499cb530f7ce9eaf48abb8d1c435 to your computer and use it in GitHub Desktop.

Build

Add a Dockerfile to the directory with the jar file:

Dockerfile

# syntax=docker/dockerfile:1

FROM eclipse-temurin:17-jdk-jammy

WORKDIR /app
COPY *.jar app.jar

CMD ["java", "-jar", "app.jar"]

Then, build and push the image:

docker build . --tag $DOCKER_ID/jarapp:amd64
docker push $DOCKER_ID/jarapp:amd64

Deploy as server

Finally, deploy to TAP:

tanzu apps workload create jar-app \
  --type server \
  --label app.kubernetes.io/part-of=jar-app \
  --image $DOCKER_ID/jarapp:amd64

Once it is up and running, port-forward to the service:

kubectl port-forward service/jar-app 8080:8080

And, then curl the end point:

% curl localhost:8080
Greetings from Spring Boot + Tanzu!

Deploy as Knative service

If you prefer a Knative service then use this to deploy:

tanzu apps workload create jar-app-ksvc \
  --type web \
  --label app.kubernetes.io/part-of=jar-app-ksvc \
  --annotation autoscaling.knative.dev/min-scale=1 \
  --image $DOCKER_ID/jarapp:amd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment