With Project Flogo™ you can visually create Ultralight Edge Microservices and run them anywhere. But what if we want to deploy these applications to Pivotal Cloud Foundry?
- Access to a Pivotal Cloud Foundry (PCF) cluster. This cluster must accept the deployment of Docker based containers.
- A sample Project Flogo application. Something simple, can be a "Hello World". You can follow this guide for more help: https://tibcosoftware.github.io/flogo/getting-started/quickstart/
- A DockerHub account and some knowledge around DockerHub.
- Docker installed locally
With the file generated out of Flogo, we need to create a Dockerimage. This can be done with the following Dockerfile:
# Dockerfile for flogoapp # VERSION 0.0.1 # The FROM instruction initializes a new build stage and sets the Base # Image for subsequent instructions. # We’re using alpine because of the small size FROM alpine # The ADD instruction copies new files, directories or remote file URLs # from <src> and adds them to the filesystem of the image at the path # <dest>. # We’ll add the flogoapp, built using the Web UI, to the working # directory ADD flogoapp.dms . # The EXPOSE instruction informs Docker that the container listens on # the specified network ports at runtime. # The app we’re using listens on port 8080 by default EXPOSE 8080 # The main purpose of a CMD is to provide defaults for an executing # container. # In our case we simply want to run the app CMD ./flogoapp.dms
To build the App run the following (please note, the Dockerfile and Flogo app must be within the same folder):
docker build . -t <your username>/flogoalpine
Once generated, you should have a local version of the Docker image within your local repository. We now need to push this up to our DockerHub account. This can be done with the following (for the simplicity, leave it as a public image):
docker push <your username>/flogoalpine
Now to deploy this on to our PCF cluster, the diego_docker flag must be enabled. It may be enabled by default or your administrator will have to do so.
Once enabled run the following:
$ cf push <app_name> -o <your username>/flogoalpine
Where <app_name> is what you want your app to be named and <your username> is your Dockerhub username. After waiting for a minute or two, you should see that your application has been deployed. Test it out by going to the URL provided by your terminal and adding a /helloworld to the end. You should see an ID value appear.
Feel free to check out a similar article that walksthrough the deployment of a Project Flogo app to Kubernetes: https://hackernoon.com/deploying-flogo-apps-to-kubernetes-43a74742e323