Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require)...
Transcript of Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require)...
![Page 1: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/1.jpg)
background image: 960x540 pixels - send to back of slide and set to 80% transparency
Twin Cities Cloud Foundry MeetupDecember 1, 2016
Image credit - http://www.rmeoc.org/wp-content/uploads/2016/07/foundry.jpg
![Page 2: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/2.jpg)
Agenda
● Local Meetup Business● Buildpacks
![Page 3: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/3.jpg)
3
Some Meetup Business
![Page 4: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/4.jpg)
Looking For Meetup Co Organizers
Role changes for Dave and I have me seeking folks to replace Dave and assist me
Image credit - http://www.casfm.org/help_wanted/help_wanted1.jpg
![Page 5: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/5.jpg)
Input on Next Year
● Days of week● Timing in month● Duration● Location
![Page 6: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/6.jpg)
But First A little about me• Andrew Ripka
• @rippmn
• State transition negotiator
![Page 7: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/7.jpg)
7
Tonight’s Presentation
![Page 8: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/8.jpg)
background image: 960x540 pixels - send to back of slide and set to 80% transparency
Structure and Opinions - BuildpacksAndrew Ripka@rippmn
Image credit - http://www.rmeoc.org/wp-content/uploads/2016/07/foundry.jpg
![Page 9: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/9.jpg)
Topics
● Structure and Opinions● Buildpack Basics● Developing Buildpacks● Example Buildpacks
![Page 10: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/10.jpg)
References
Material Sourced from https://docs.cloudfoundry.org/buildpacks/https://docs.pivotal.io/pivotalcf/1-8/buildpacks https://github.com/cloudfoundry/buildpack-packager
![Page 11: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/11.jpg)
Structure and Opinions
![Page 12: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/12.jpg)
Structured
Opinionated
![Page 13: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/13.jpg)
Structured
OpinionatedLogs
Lumber
Treehouse
![Page 14: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/14.jpg)
Stronger Guarantees
More Defaults
![Page 15: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/15.jpg)
Structured
OpinionatedLogs
Lumber
TreehouseKit
DIY Treehouse
![Page 16: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/16.jpg)
Cloud Foundry Structure and Opinions
● Cloud Foundry is a “Foundry”○ workshop or factory for casting metal.
● Structure - coherent form or organization ● Framework - a basic structure underlying a system, concept, or
text.● Opinions - Specific Implementation of Something● Cloud Foundry really a framework for expressing opinions
![Page 17: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/17.jpg)
17
Buildpacks
![Page 18: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/18.jpg)
Buildpacks
• The thing that makes it possible to take the developer provided app source or binary and run on Cloud Foundry
• combines the application with the frameworks and runtimes necessary to deploy
• Usually written as Ruby scripts (can also be written as Shell)• Installed into a Cloud Foundry instance or loaded from an external
location
![Page 19: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/19.jpg)
Build API - (The Structure)
• detect validate if buildpack should be applied by examining user provided artifacts or code– Executed for multiple buildpacks based upon configured order
• compile - assemble container file by combining application code and defined runtime components
• release describe how app container can be deployed and run on an assigned container host
![Page 20: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/20.jpg)
• System Buildpacks• Community Buildpacks• Custom Buildpacks - write your own
Buildpack Implementations (The Opinions)
![Page 21: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/21.jpg)
• Cloud Foundry Provided buildpacks for commonly used languages– Binary– Go– Java– Node.js– .Net Core– PHP– Python– Ruby– Staticfile
System Buildpacks
![Page 22: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/22.jpg)
Community and Heroku Buildpacks
● Community Created Buildpacks can be found at○ https://github.com/cloudfoundry-community/cf-docs-contrib/wi
ki/Buildpacks#community-created● Heroku Buildpacks
○ https://devcenter.heroku.com/articles/buildpacks#officially-supported-buildpacks
● Heroku 3rd Party Buildpacks○ https://devcenter.heroku.com/articles/third-party-buildpacks
![Page 23: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/23.jpg)
Your Own Opinions
● You can extend existing system buildpacks (or a community one)○ Fork Github repo
● Write your own (More on this later)○ https://docs.cloudfoundry.org/buildpacks/developing-bui
ldpacks.html
● ROADMAP - Extend through build pack chain
![Page 24: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/24.jpg)
Buildpack ControlOpinions for Admins/Operators
● Available Buildpacks and details controlled by Admin● Disable Custom Buildpacks
○ Developers pushing apps are restricted to those installed by operators ● Install new custom buildpacks
cf create-buildpack BUILDPACK PATH POSITION [--enable|--disable]
● Delete unusedcf delete-buildpack BUILDPACK [-f]
● Update existing buildpack (change order, new version etc)cf update-buildpack BUILDPACK [-p PATH] [-i POSITION] [--enable|--disable] [--lock|--unlock]
![Page 25: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/25.jpg)
Using Buildpacks
● Push artifacts matching the detection criteria of the buildpack○ Simplest way, and best way to ensure conformance with operators
desires○ Con here is staging app might take longer
● Specify buildpack during application push
○ Provide Name of buildpack or Git URL ○ Using push command flag (-b)
cf push z-load-port -b https://github.com/aripka-pivotal/cf-buildpack-jmeter
○ Using Manifest entryapplications:- name: workshop memory: 512M instances: 1 path: ./target/cf-spring-mvc-boot-0.0.1-SNAPSHOT.jar buildpack: java_buildpack_offline
![Page 26: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/26.jpg)
Custom Start Commands
26
● Certain Buildpacks allow (or require) you to provide a start command○ Binary buildpack and python
● At push time this can be specified in manifest or with push flag “-c”● Can also be configured via a text file named “Procfile”
○ Specify process type and command○ Example Binary Buildpack
web: ./app
http://docs.pivotal.io/pivotalcf/1-8/buildpacks/prod-server.htmlhttp://docs.pivotal.io/pivotalcf/1-6/buildpacks/binary/
![Page 27: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/27.jpg)
How Buildpacks are usedThe Staging Process
● Run as Tasks ● Task downloads
buildpack(s) and if present, the app’s buildpack cache.
● Executes detect on available buildpacks exiting on match (Skipped if specified)
● Detected Buildpack used to build the droplet
● Droplet stored in CC Blobstore so it can be started as Long Running Process
![Page 28: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/28.jpg)
28
Developing Custom Buildpack
![Page 29: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/29.jpg)
The Basics
29
● 3 Scripts○ bin/detect○ bin/compile○ bin/release
● Put in git repo
![Page 30: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/30.jpg)
Advanced
30
● For environments with custom buildpacks disabled○ Need to package so can be installed by Admin/Operator
● Cloud Foundry installation limited connectivity or disconnected○ Can define a proxy in application manifest○ Use Buildpack Packager to create buildpack for installation
with dependencies cached■ https://github.com/cloudfoundry/buildpack-packager/blob/master/doc/disconnected_en
vironments.md
![Page 31: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/31.jpg)
bin/detect
31
● Determines whether or not to apply the buildpack to an app. ● Called with one argument, build directory containing the app files
uploaded by cf push.● Returns 0 if buildpack compatible with app
○ system buildpacks also print the buildpack name, version, and other helpful information to STDOUT.
![Page 32: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/32.jpg)
Example bin/detect
32
● Ruby script that checks for a Ruby app based on the existence of a Gemfile:#!/usr/bin/env ruby
gemfile_path = File.join ARGV[0], "Gemfile"
if File.exist?(gemfile_path) puts "Ruby" exit 0else exit 1end
![Page 33: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/33.jpg)
bin/compile
33
● Builds a droplet by packaging the app dependencies necessary to run App.
● Script is run with two arguments: ○ build directory containing the app files uploaded by cf push○ cache directory the buildpack can use to store assets during
the build process for future executions on same staging cell
![Page 34: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/34.jpg)
Example bin/compile
34
● Ruby script that downloads and installs ruby (detail not shown)#!/usr/bin/env ruby#sync output$stdout.sync = truebuild_path = ARGV[0]cache_path = ARGV[1]
install_ruby
private def install_ruby puts "Installing Ruby" # !!! build tasks go here !!! # download ruby # install rubyend
![Page 35: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/35.jpg)
bin/release
35
● Provides metadata to Cloud Foundry indicating how the app should be executed.
● Called with one argument, build directory containing the app files uploaded by cf push and operated on by detect and compile.
● The script return the contents of YAML file in the following format:
default_process_types: web: start_command.filetype
● Custom variables will be added if .profile.d file supplied in root directory of app (also supported in some buildpacks)
http://docs.pivotal.io/pivotalcf/1-8/buildpacks/custom.html
![Page 36: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/36.jpg)
Example bin/release
36
● Bash returns the yml text to start process#!/usr/bin/env bash
# bin/release <build-dir>
echo -e "---\ndefault_process_types:\n web: sh boot.sh"
![Page 37: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/37.jpg)
37
Custom Buildpack Examples
![Page 38: Cloud Foundry Meetup Twin Cities · Custom Start Commands 26 Certain Buildpacks allow (or require) you to provide a start command Binary buildpack and python At push time this can](https://reader034.fdocuments.net/reader034/viewer/2022052020/603413a86bdbb22a5b1852e2/html5/thumbnails/38.jpg)
Simple Example Walkthrough
Mule Buildpackhttps://github.com/aripka-pivotal/cf-buildpack-mule (note currently not working as asset downloads no longer exist)
Test withhttps://docs.mulesoft.com/mule-user-guide/v/3.3/bookstore-example
Jmeter Buildpackhttps://github.com/aripka-pivotal/cf-buildpack-jmeter/tree/master/bin