3. Deploying Docker Applications

Starting with version 1.2, it is possible to register and deploy Docker based apps as part of streams and tasks using Data Flow for Cloud Foundry.

If you are using Spring Boot and RabbitMQ based Docker images you can provide a common deployment property to facilitate the apps binding to the RabbitMQ service. Assuming your RabbitMQ service is named rabbit you can provide the following:

cf set-env dataflow-server SPRING_APPLICATION_JSON '{"spring.cloud.dataflow.applicationProperties.stream.spring.rabbitmq.addresses": "${vcap.services.rabbit.credentials.protocols.amqp.uris}"}'

For Spring Cloud Task apps, something similar to the following could be used, if using a database service instance named mysql:

cf set-env SPRING_DATASOURCE_URL '${vcap.services.mysql.credentials.jdbcUrl}'
cf set-env SPRING_DATASOURCE_USERNAME '${vcap.services.mysql.credentials.username}'
cf set-env SPRING_DATASOURCE_PASSWORD '${vcap.services.mysql.credentials.password}'
cf set-env SPRING_DATASOURCE_DRIVER_CLASS_NAME 'org.mariadb.jdbc.Driver'

For non-Java or non-Boot apps, your Docker app would have to parse the VCAP_SERVICES variable in order to bind to any available services.

[Note]Passing application properties

When using non-boot apps, chances are that you want the application properties passed to your app using traditional environment variables, as opposed to using the special SPRING_APPLICATION_JSON variable. To achieve this, set the following variables for streams and tasks, respectively:

SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_STREAM_USE_SPRING_APPLICATION_JSON=false
SPRING_CLOUD_DEPLOYER_CLOUDFOUNDRY_TASK_USE_SPRING_APPLICATION_JSON=false