A Spring Boot 3.5 / Java 21 application that invokes a Python script via ProcessBuilder.
The Python environment (including pandas) is shipped as a conda-pack tarball and unpacked at application startup on CloudFoundry.
CloudFoundry is configured with two buildpacks in manifest.yaml:
| Order | Buildpack | Role |
|---|---|---|
| 1 | python_buildpack |
Supply buildpack -- installs a base Python runtime into the droplet |
| 2 | java_buildpack_offline |
Final buildpack -- provides the JVM, memory calculator and start command for the Spring Boot app |
The first buildpack only supplies dependencies; the last one owns the process type and start command.
Rather than relying on pip install at staging time, the Python packages (pandas, etc.) are pre-built into a portable conda-pack tarball (python_env.tar.gz).
This tarball is created inside a linux/amd64 Docker container so the native binaries match the CloudFoundry stack, even when building on macOS (Apple Silicon or Intel).
At application startup the CF .profile script unpacks the tarball and activates the environment before the JVM starts.
The deploy.sh script uses the jar xf command to upack the contents of the JAR file to the deploy directory.
This allows the java_buildpack_offline to detect and run the application correctly in a multi-buildpack setup.
After running deploy.sh, the pushed directory looks like this:
deploy/
├── .profile # CF startup hook -- unpacks conda env
├── requirements.txt # Empty -- triggers python_buildpack detection
├── runtime.txt # Python version hint for python_buildpack
├── python_env.tar.gz # Conda-pack tarball (Python 3.11 + pandas)
├── scripts/
│ └── hello.py # Python script invoked by the Spring Boot app
└── BOOT-INF/ # Extracted Spring Boot JAR
├── META-INF/
└── org/
- Java 21
- Maven (or use the included
mvnwwrapper) - Docker (for building the conda-pack tarball on macOS)
- CF CLI (
cf) logged in to a CloudFoundry environment
This runs inside a Docker container so the resulting tarball contains linux-amd64 binaries:
./conda/pack-env.shThe script produces python_env.tar.gz in the project root.
./deploy.shThis will:
- Build the Spring Boot fat JAR via Maven
- Extract it into
deploy/ - Copy the Python script,
.profile,requirements.txt,runtime.txtandpython_env.tar.gzintodeploy/
cf pushcurl https://<app-route>/run-pythonExpected output:
=== Hello from Python with Pandas! ===
Pandas version: 2.x.x
Language scores:
language score
Java 85
Python 92
Go 78
Rust 88
Average score: 85.8
Top language: Python
=== Done ===