2025-10-20 13:34:33 -05:00
2025-10-20 12:25:03 -05:00
2025-10-20 11:07:35 -05:00
2025-10-20 12:25:03 -05:00
2025-10-20 11:07:35 -05:00
2025-10-20 12:25:03 -05:00
2025-10-20 11:07:35 -05:00
2025-10-20 11:07:35 -05:00
2025-10-20 13:34:33 -05:00

CF Deployer - Cloud Foundry Deployment Service

A Spring Boot application that provides a REST API for deploying Java applications to Cloud Foundry/Tanzu environments.

Prerequisites

  • Java 21
  • Gradle 8.14

Build and Run

Build the application

./gradlew clean build

Run the application

./gradlew bootRun

Or run the JAR directly:

java -jar build/libs/cf-uploader-1.0.0.jar

The application will start on http://localhost:8080

API Endpoint

Deploy Application to Cloud Foundry

Endpoint: POST /api/cf/deploy

Content-Type: multipart/form-data

Request Parts:

  • request (JSON string): Deployment configuration
  • jarFile (file): The Java application JAR file
  • manifest (file): Cloud Foundry manifest.yml file

Sample cURL Request

curl -X POST http://localhost:8080/api/cf/deploy \
  -F 'request={
    "apiEndpoint": "https://api.cf.example.com",
    "username": "your-username",
    "password": "your-password",
    "organization": "your-org",
    "space": "your-space",
    "appName": "my-app",
    "skipSslValidation": false
  }' \
  -F 'jarFile=@/path/to/your/application.jar' \
  -F 'manifest=@/path/to/manifest.yml'

Sample Request with Skip SSL Validation

curl -X POST http://localhost:8080/api/cf/deploy \
  -F 'request={
    "apiEndpoint": "https://api.sys.tanzu.example.com",
    "username": "admin",
    "password": "admin123",
    "organization": "development",
    "space": "dev",
    "appName": "sample-app",
    "skipSslValidation": true
  }' \
  -F 'jarFile=@./sample-app.jar' \
  -F 'manifest=@./manifest.yml'

Sample Manifest File (manifest.yml)

---
applications:
- name: sample-app
  memory: 1G
  instances: 2
  path: sample-app.jar
  buildpacks:
  - java_buildpack
  env:
    SPRING_PROFILES_ACTIVE: production

Request Parameters

Field Type Required Description
apiEndpoint String Yes Cloud Foundry API endpoint URL
username String Yes CF username
password String Yes CF password
organization String Yes Target CF organization
space String Yes Target CF space
appName String Yes Application name
skipSslValidation Boolean Yes Skip SSL certificate validation

Response Format

Success Response

{
  "success": true,
  "message": "Application deployed successfully",
  "deploymentId": "123e4567-e89b-12d3-a456-426614174000",
  "output": "CF CLI output logs...",
  "error": null
}

Error Response

{
  "success": false,
  "message": "Application deployment failed",
  "deploymentId": "123e4567-e89b-12d3-a456-426614174000",
  "output": "CF CLI output logs...",
  "error": "Error details..."
}

Configuration

Application settings can be configured in src/main/resources/application.properties:

# Server port
server.port=8080

# Max file size (default: 500MB)
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB

# CF CLI timeout in seconds (default: 600)
cf.cli.timeout=600

# Optional: Custom CF CLI path (if not using bundled binaries)
cf.cli.path=

Features

  • RESTful API for CF deployments
  • Automatic CF CLI binary management (Linux, macOS, Windows)
  • Secure password handling (masked in logs)
  • Configurable timeout for long-running deployments
  • Comprehensive error handling
  • Multipart file upload support up to 500MB
  • Automatic cleanup of temporary files

Error Handling

The API handles various error scenarios:

  • 400 Bad Request: Invalid request parameters or file validation errors
  • 413 Payload Too Large: Files exceed 500MB limit
  • 500 Internal Server Error: Deployment failures or unexpected errors

Development

Project Structure

src/main/java/com/cfdeployer/
├── controller/          # REST controllers
├── service/            # Business logic
├── model/              # DTOs
└── exception/          # Exception handlers

src/main/resources/
├── application.properties
└── cf-cli/             # CF CLI binaries (auto-downloaded)

Build with Custom CF CLI Version

Edit build.gradle to change the CF CLI version:

def cfCliVersion = '8.7.10'  // Change this version

License

This project is licensed under the MIT License.

Description
No description provided
Readme 18 MiB
Languages
Java 54.1%
Shell 20.4%
TypeScript 10.5%
CSS 7.1%
HTML 6.6%
Other 1.3%