This repository extends the official Spring PetClinic application with container images, Helm deployments, and GCP delivery workflows.
Production path for this fork:
| Piece | Location |
|---|---|
| Dockerfile | Dockerfile at repo root (Temurin 17 JRE, non-root petclinic user) |
| Helm chart | chart/petclinic |
| Env values | values-dev.yaml / values-prod.yaml |
| PR / release CI | .github/workflows/pr-release.yml, .github/workflows/main-release.yml |
| Deploy to dev | .github/workflows/deploy-dev.yml (push to main) |
| Manual deploy | .github/workflows/manual-deploy.yml (prod, or redeploy a chosen tag) |
App resources deploy to the petclinic namespace (not default). That namespace must match the Workload Identity binding in the infra repo (petclinic/petclinic → GCP app SA).
App workflows run on Actions Runner Controller scale sets in the env GKE cluster (petclinic-arc-dev / petclinic-arc-prod), not on long-lived GCE VMs.
| Workflow | runs-on |
Registry |
|---|---|---|
| PR gatekeeper | petclinic-arc-dev |
dev Artifact Registry only (no deploy) |
| Deploy to dev | petclinic-arc-dev |
dev registry, then Helm to the shared petclinic namespace |
| Main release | petclinic-arc-prod |
prod Artifact Registry only (no deploy) |
| Manual deploy | petclinic-arc-${{ environment }} |
reads the matching env registry |
Trust model: runner pods use GKE Workload Identity (arc-runners K8s SA → github-app-runner-sa-{env}). There is no GitHub→GCP OIDC in these workflows (id-token: write is intentionally absent). Images are built with rootless BuildKit (no Docker socket / DinD); Trivy scans the image tar before crane push.
Project identifiers are not secrets. Dev and prod are different GCP projects, so set GCP_PROJECT_ID and GCP_REGION on the GitHub Environments named dev and prod (Settings → Environments), not as a single repository variable.
| Variable | dev Environment |
prod Environment |
|---|---|---|
GCP_PROJECT_ID |
Dev GCP project ID | Prod GCP project ID |
GCP_REGION |
europe-west1 |
europe-west1 |
PR Gatekeeper and Deploy to dev use Environment dev. Main release uses prod. Manual deploy uses the Environment you select. Workflows fail fast if either variable is empty on that Environment. Keep authenticators (tokens, PEMs, passwords) as secrets — not these IDs.
A merge to main is what updates the shared dev cluster (build, scan, push, Helm). Pull requests only prove the change. Production stays a manual promote of a SemVer tag.
Committed values-dev.yaml / values-prod.yaml hold only env-specific non-project settings (replicas, ingress host, environment label, K8s SA name). Project-bound Helm fields are injected at deploy time from the variables above (deterministic names matching the infra modules):
image.repository→{REGION}-docker.pkg.dev/{PROJECT_ID}/petclinic-repo-{env}/petclinicgoogleProjectId→$GCP_PROJECT_IDserviceAccount.gcpEmail→petclinic-sa-{env}@$GCP_PROJECT_ID.iam.gserviceaccount.comcloudSql.instanceConnectionName→$GCP_PROJECT_ID:$GCP_REGION:petclinic-db-{env}
deploy-dev.yml and manual-deploy.yml pass those via --set. Chart defaults leave those four fields empty.
# Example (credentials and cluster already configured)
PROJECT_ID=<GCP_PROJECT_ID>
REGION=<GCP_REGION>
ENV=dev
helm upgrade --install petclinic ./chart/petclinic \
--namespace petclinic \
--create-namespace \
--values ./chart/petclinic/values-${ENV}.yaml \
--set image.repository=${REGION}-docker.pkg.dev/${PROJECT_ID}/petclinic-repo-${ENV}/petclinic \
--set image.tag=<tag> \
--set googleProjectId=${PROJECT_ID} \
--set serviceAccount.gcpEmail=petclinic-sa-${ENV}@${PROJECT_ID}.iam.gserviceaccount.com \
--set cloudSql.instanceConnectionName=${PROJECT_ID}:${REGION}:petclinic-db-${ENV} \
--waitExternal access is via the ingress-nginx LoadBalancer (source-restricted in infra), not the app ClusterIP Service. Actuator is limited to health, info, and prometheus; probes use /actuator/health/liveness and /actuator/health/readiness.
Primary cluster path: the chart’s ServiceMonitor scrapes Service port http-web → /actuator/prometheus (Micrometer). Prometheus job label is petclinic (jobLabel: app.kubernetes.io/name). Alerts live in PrometheusRule (e.g. PetclinicInstanceDown); the Micrometer JVM dashboard ConfigMap is labeled grafana_dashboard: "1" for the Grafana sidecar.
Non-primary: the image still runs the JMX Prometheus Java agent on container port 9093 for local/debug use. That port is not on the Kubernetes Service and is not scraped in-cluster.
Infra stack details (retention, Grafana password, demo checklist): capstone-project-infra docs/monitoring.md.
Legacy manifests under k8s/ are local demos only — do not apply them to the GKE clusters.
Infrastructure (GKE, Cloud SQL, WI, Ingress, monitoring) lives in capstone-project-infra.
See the presentation here: Spring Petclinic Sample Application (legacy slides)
Note: These slides refer to a legacy, pre–Spring Boot version of Petclinic and may not reflect the current Spring Boot–based implementation. For up-to-date information, please refer to this repository and its documentation.
Spring Petclinic is a Spring Boot application built using Maven or Gradle. Java 17 or later is required for the build, and the application can run with Java 17 or newer.
You first need to clone the project locally:
git clone https://github.com/njakov/capstone-project-app.git
cd capstone-project-appIf you are using Maven, you can start the application on the command-line as follows:
./mvnw spring-boot:runWith Gradle, the command is as follows:
./gradlew bootRunYou can then access the Petclinic at http://localhost:8080/.
You can, of course, run Petclinic in your favorite IDE. See below for more details.
This fork ships a root Dockerfile used by the CI pipelines (JAR + checksum-pinned JMX agent). Build after assembling the JAR:
./mvnw -DskipTests package
# CI stages spring-petclinic.jar + jmx.jar before the image build
docker build -t petclinic:local .CI on ARC uses rootless BuildKit instead of docker build (same Dockerfile).
You can also build a container image with the Spring Boot build plugin (if you have a docker daemon):
./mvnw spring-boot:build-imagedocker images | grep petclinic
docker run -p 8080:8080 docker.io/library/spring-petclinic:latestOur issue tracker is available here.
In its default configuration, Petclinic uses an in-memory database (H2) which
gets populated at startup with data. The h2 console is exposed at http://localhost:8080/h2-console,
and it is possible to inspect the content of the database using the jdbc:h2:mem:<uuid> URL. The UUID is printed at startup to the console.
A similar setup is provided for MySQL and PostgreSQL if a persistent database configuration is needed. Note that whenever the database type changes, the app needs to run with a different profile: spring.profiles.active=mysql for MySQL or spring.profiles.active=postgres for PostgreSQL. See the Spring Boot documentation for more detail on how to set the active profile.
You can start MySQL or PostgreSQL locally with whatever installer works for your OS or use docker:
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:9.7or
docker run -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 postgres:18.4Further documentation is provided for MySQL and PostgreSQL.
Instead of vanilla docker you can also use the provided docker-compose.yml file to start the database containers. Each one has a service named after the Spring profile:
docker compose up mysqlor
docker compose up postgresAt development time we recommend you use the test applications set up as main() methods in PetClinicIntegrationTests (using the default H2 database and also adding Spring Boot Devtools), MySqlTestApplication and PostgresIntegrationTests. These are set up so that you can run the apps in your IDE to get fast feedback and also run the same classes as integration tests against the respective database. The MySql integration tests use Testcontainers to start the database in a Docker container, and the Postgres tests use Docker Compose to do the same thing.
There is a petclinic.css in src/main/resources/static/resources/css. It was generated from the petclinic.scss source, combined with the Bootstrap library. If you make changes to the scss, or upgrade Bootstrap, you will need to re-compile the CSS resources using the Maven profile "css", i.e. ./mvnw package -P css. There is no build profile for Gradle to compile the CSS.
The following items should be installed in your system:
- Java 17 or newer (full JDK, not a JRE)
- Git command line tool
- Your preferred IDE
- Eclipse with the m2e plugin. Note: when m2e is available, there is a m2 icon in
Help -> Aboutdialog. If m2e is not there, follow the installation process here - Spring Tools Suite (STS)
- IntelliJ IDEA
- VS Code
- Eclipse with the m2e plugin. Note: when m2e is available, there is a m2 icon in
-
On the command line run:
git clone https://github.com/njakov/capstone-project-app.git
-
Inside Eclipse or STS:
Open the project via
File -> Import -> Maven -> Existing Maven project, then select the root directory of the cloned repo.Then either build on the command line
./mvnw generate-resourcesor use the Eclipse launcher (right-click on project andRun As -> Maven install) to generate the CSS. Run the application's main method by right-clicking on it and choosingRun As -> Java Application. -
Inside IntelliJ IDEA:
In the main menu, choose
File -> Openand select the Petclinic pom.xml. Click on theOpenbutton.-
CSS files are generated from the Maven build. You can build them on the command line
./mvnw generate-resourcesor right-click on thespring-petclinicproject thenMaven -> Generates sources and Update Folders. -
A run configuration named
PetClinicApplicationshould have been created for you if you're using a recent Ultimate version. Otherwise, run the application by right-clicking on thePetClinicApplicationmain class and choosingRun 'PetClinicApplication'.
-
-
Navigate to the Petclinic
Visit http://localhost:8080 in your browser.
| Spring Boot Configuration | Class or Java property files |
|---|---|
| The Main Class | PetClinicApplication |
| Properties Files | application.properties |
| Caching | CacheConfiguration |
The Spring Petclinic "main" branch in the spring-projects GitHub org is the "canonical" implementation based on Spring Boot and Thymeleaf. There are quite a few forks in the GitHub org spring-petclinic. If you are interested in using a different technology stack to implement the Pet Clinic, please join the community there.
One of the best parts about working on the Spring Petclinic application is that we have the opportunity to work in direct contact with many Open Source projects. We found bugs/suggested improvements on various topics such as Spring, Spring Data, Bean Validation and even Eclipse! In many cases, they've been fixed/implemented in just a few days. Here is a list of them:
| Name | Issue |
|---|---|
| Spring JDBC: simplify usage of NamedParameterJdbcTemplate | SPR-10256 and SPR-10257 |
| Bean Validation / Hibernate Validator: simplify Maven dependencies and backward compatibility | HV-790 and HV-792 |
| Spring Data: provide more flexibility when working with JPQL queries | DATAJPA-292 |
The issue tracker is the preferred channel for bug reports, feature requests and submitting pull requests.
For pull requests, editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at https://editorconfig.org. All commits must include a Signed-off-by trailer at the end of each commit message to indicate that the contributor agrees to the Developer Certificate of Origin. For additional details, please refer to the blog post Hello DCO, Goodbye CLA: Simplifying Contributions to Spring.
The Spring PetClinic sample application is released under version 2.0 of the Apache License.
