Deploy to Pivotal Cloud Foundry
The first thing we need to do is to generate a docker image and push it to any registry. We will use the DockerHub registry for this example.
You can use any Docker Registry that you want, either DockerHub, any private Docker Registry, or GCR. If you want more information about how to deploy from any of this registries you should check this link
Docker Image Publish
There are four steps to publish a Docker Image to DockerHub:
- Register to DockerHub SignUp
- Once logged in, create a repository for each image. The field Name is the name of the docker image. This is the identifier along with the account name.
- Edit the
docker-release.shfor each service, naming each repository (<ACCOUNT_USERNAME>/<REPOSITORY_NAME>)
- With correctly configured services, run
Once the script finishes, the docker image is published to DockerHub and ready to be deployed.
Docker Image Implementation
Simple Dockerfile extending from
maven image. The build part of the image just install the dependencies and generates the package (jar file), the runtime of the Dockerfile runs the jar generated by the build.
Pivotal Cloud Foundry
With the images pushed to DockerHub, push them to the Pivotal Cloud Foundry platform.
The first requirement is to create an account in Pivotal. Obtain access to the console and then create an organization manually. It's as simple as entering input inside Create an Org.
The next step is to install the CF CLI in our computer. There is a guide to help you with this that is provided by your platform. See PCF CLI Install
Once the Cloud Foundry CLI is installed on your machine, login to your Pivotal account:
$ cf login -a https://api.run.pivotal.io
With a connection, use the Cloud Foundry CLI within your account. One-by-one, change directories to each service project and run:
$ cf push
backservice deployed, create a policy to allow connections from
backservice using the
tcp protocol on port
8082 is the configured
To do so, run this command:
$ cf add-network-policy frontservice --destination-app backservice --port 8082 --protocol tcp
How does it work?
For each service created there is a
manifest.yml with all the configuration needed for deployment to Cloud Foundry.
frontservice knows about
backservice host from an environment variable set in