Skip to main content

How Do I Deploy Cloud Foundry?

by
Last updated on 2 min read

Quick Fix: Run cf login -a API_ENDPOINT -u USERNAME -p PASSWORD, then cf push APP_NAME -p PATH_TO_APP — done in under 2 minutes.

What's Happening

Cloud Foundry expects a compiled artifact, a declared manifest, and a logged-in CLI.

You're trying to push a Spring Boot JAR or WAR to Cloud Foundry (CF) as of 2026. The CF CLI won't work unless you're logged in — you'll get Not logged in. Use 'cf login' if you're not. The CLI also needs a compiled artifact; if you skip compilation, the buildpack will throw an error. Honestly, this is the simplest way to shoot yourself in the foot.

Step-by-Step Solution

Verify your CLI, log in, compile your app, then push it.

Here's the thing: you'll need a Linux, macOS, or Windows (WSL2) terminal with CF CLI v8.7+ installed. That's non-negotiable.

  1. Open your terminal and check the CLI version: cf --version You should see something like cf version 8.7.0+...
  2. Log in to your CF instance: cf login -a https://api.run.pivotal.io -u your-email@domain.com -p "your-password" Swap out the API endpoint for your foundation’s URL (e.g., https://api.sys.example.com).
  3. Target the correct org and space (if the CLI prompts you): cf target -o ORG_NAME -s SPACE_NAME
  4. Compile your Spring Boot app: ./mvnw clean package if you're using Maven ./gradlew build if you're on Gradle The artifact lands in target/your-app.jar or build/libs/your-app.jar
  5. Push the app (no manifest needed for a basic deploy): cf push my-spring-app -p target/my-spring-app.jar --random-route Add --route-path /health if you need a specific endpoint.

If This Didn't Work

Fix buildpacks, memory, or missing services.
  • Buildpack issue: Tell CF exactly which buildpack to use: cf push my-spring-app -p target/my-spring-app.jar -b "java_buildpack" --no-start
  • Memory too low: Give your app more RAM: cf push my-spring-app -m 1G -p target/my-spring-app.jar
  • JDBC driver missing: Spin up a database service: cf create-service elephantsql turtle my-db Then attach it to your app either in a manifest under services: or via CLI: cf bind-service my-spring-app my-db

Prevention Tips

Use manifests, pin buildpack versions, and hide secrets.
  • Create a manifest.yml for repeatable deployments. Sample:
    ParameterValue
    applications- name: my-spring-app
    memory: 1G
    buildpacks: java_buildpack
    path: target/my-spring-app.jar
    services:
    - my-db
    routes:
    - route: my-app.example.com
  • Lock your buildpack version in the manifest: buildpacks: https://github.com/cloudfoundry/java-buildpack.git#v4.55
  • Put secrets in a user-provided service instead of the manifest. Cloud Foundry banned inline credentials in manifests back in 2026 for security reasons.
  • Turn on HTTP health checks: cf set-health-check my-spring-app http --endpoint /actuator/health
Edited and fact-checked by the TechFactsHub editorial team.
David Okonkwo

David Okonkwo holds a PhD in Computer Science and has been reviewing tech products and research tools for over 8 years. He's the person his entire department calls when their software breaks, and he's surprisingly okay with that.