Skip to content

Latest commit

 

History

History
57 lines (33 loc) · 3.57 KB

DEPLOY.md

File metadata and controls

57 lines (33 loc) · 3.57 KB

Deploy to Pivotal Cloud Foundry

Docker

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

  1. Register to DockerHub

  2. 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.

  3. After that, login to the registry with your docker cli by typing docker login in your shell (terminal window).

  4. Now you are ready to push your image to DockerHub repository using docker-release.sh

     ./docker-release.sh <account_name/name>
    

Once the script finishes, the docker image is published to DockerHub and ready to be deployed.

Docker Image Implementation

The Dockerfile is implemented using MultiStage build:

  • The build stage extends FROM maven:alpine. The single responsibility of this stage is to install dependencies (caching layers) and generate the jar.
  • The runtime stage extends FROM openjdk:alpine and works executing the jar generated by build stage. It will EXPOSE the external ports to the host.

Pivotal Cloud Foundry

Now that the images pushed to DockerHub, push them into Pivotal 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

A Cloud Foundry connection is established using your Pivotal account. Copy the example-manifest.yml to your project and rename it to manifest.yml. Open the manifest file and edit the three configurable variables:

  1. service_name: The name of the service inside the Pivotal Cloud Foundry platform.
  2. docker_image: The docker image name is composed with your account and the repository (e.g: vlingo/project1)
  3. subdomain: This is your public end-point within domain .cfapps.io

You may also configure environment variables, instances, memory, disk quota, etc. See Deploying with Application Manifests for possible manifest configurations.

Along with your configured manifest.yml, push your project:

$ cf push

This command by default checks whether a manifest.yml exists in the directory, and if so, uses it to push to the platform.

That's all it takes! The service/application is in the Pivotal Cloud Foundry, deployed and working. Use the Pivotal Console to see your services, the logs, and any other project infrastructure artifacts.

See the xoom-examples repository for a working configuration. This demonstrates how to integrate two or more services that are deployed to the Pivotal Cloud Foundry platform.