Deploying to Cloud Foundry
Relevant source files
The following files were used as context for generating this wiki page:
This document outlines the process for deploying the gs-rest-service application to a Cloud Foundry environment. The deployment is configured using a manifest file that specifies the application's name, resource allocation, and the path to the deployable artifact.
The core of the deployment process relies on building an executable JAR file from the Spring Boot application and then using the manifest.yml file to instruct the Cloud Foundry platform on how to run it. This provides a declarative and repeatable method for deploying the service.
Sources: complete/manifest.yml, README.adoc:84-86
Manifest Configuration
Deployment to Cloud Foundry is defined by the complete/manifest.yml file. This file contains the metadata required by the platform to stage and run the application.
Sources: complete/manifest.yml
Manifest Properties
The manifest specifies several key attributes for the application deployment.
| Property | Value | Description |
|---|---|---|
name | gs-rest-service | The name assigned to the application within the Cloud Foundry space. |
memory | 256M | The memory limit allocated for each application instance. |
instances | 1 | The number of instances of the application to be deployed and run. |
host | rest-service | The subdomain (host) for the application's public route. |
domain | guides.spring.io | The domain for the application's public route. The resulting URL will be rest-service.guides.spring.io. |
path | build/libs/gs-rest-service-0.1.0.jar | The path to the application artifact. This path points to the JAR file generated by a Gradle build, as indicated by the build/libs directory structure used by the ./gradlew build command. |
Sources: complete/manifest.yml:2-8, test/run.sh:28-33
Manifest File Content
The complete manifest is a concise YAML file as shown below.
---
applications:
- name: gs-rest-service
memory: 256M
instances: 1
host: rest-service
domain: guides.spring.io
path: build/libs/gs-rest-service-0.1.0.jar
Sources: complete/manifest.yml:1-8
Application Build and Artifact
The path property in manifest.yml points to an executable JAR file. This artifact is the result of the project's build process. The repository is configured for both Maven and Gradle builds.
The spring-boot-maven-plugin in the pom.xml is responsible for packaging the application into an executable JAR when using Maven. The test/run.sh script demonstrates running both mvn clean package and gradlew build, either of which produces the necessary artifact. However, the manifest is specifically configured for the output path of the Gradle build.
Sources: complete/pom.xml:32-36, test/run.sh:16,28, README.adoc:84-86
The following diagram illustrates the flow from building the application to its deployment on Cloud Foundry.
This diagram shows how the build process creates a JAR file, which is then referenced by the manifest.yml and used by Cloud Foundry to deploy and run the application.
Sources: complete/manifest.yml, test/run.sh, complete/pom.xml
Summary
The gs-rest-service project is configured for straightforward deployment to Cloud Foundry via the manifest.yml file. This file declaratively sets the application's runtime properties, including its name, memory, and public route. The deployment process requires building the Spring Boot application into an executable JAR, which the manifest then points to, enabling a simple and automated push to the platform.
Sources: complete/manifest.yml, README.adoc:84-86