{"id":21696428,"url":"https://github.com/madetech/cf-deploy","last_synced_at":"2025-09-23T03:44:34.236Z","repository":{"id":17712570,"uuid":"20529391","full_name":"madetech/cf-deploy","owner":"madetech","description":"Rake tasks for deploying to CloudFoundry v6+","archived":false,"fork":false,"pushed_at":"2021-04-28T21:36:28.000Z","size":101,"stargazers_count":13,"open_issues_count":8,"forks_count":2,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-08-24T02:01:44.161Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madetech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-05T15:00:16.000Z","updated_at":"2024-05-17T16:42:16.000Z","dependencies_parsed_at":"2022-08-25T09:20:26.220Z","dependency_job_id":null,"html_url":"https://github.com/madetech/cf-deploy","commit_stats":null,"previous_names":["madebymade/cf-deploy"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/madetech/cf-deploy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fcf-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fcf-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fcf-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fcf-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madetech","download_url":"https://codeload.github.com/madetech/cf-deploy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madetech%2Fcf-deploy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275872346,"owners_count":25543611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T19:19:51.348Z","updated_at":"2025-09-23T03:44:34.216Z","avatar_url":"https://github.com/madetech.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CloudFoundry Rails Deployment\n\n[![Code Climate](https://codeclimate.com/github/madetech/cf-deploy/badges/gpa.svg)](https://codeclimate.com/github/madetech/cf-deploy)\n[![Build Status](https://travis-ci.org/madetech/cf-deploy.svg?branch=master)](https://travis-ci.org/madetech/cf-deploy)\n[![Test Coverage](https://codeclimate.com/github/madetech/cf-deploy/badges/coverage.svg)](https://codeclimate.com/github/madetech/cf-deploy/coverage)\n\n`cf-deploy` is the tool you use to deploy your rails app to\n[CloudFoundry][CloudFoundry] providers like [Pivotal][Pivotal]. It works with\nrails 4.2 and older versions as far back as rails 3.\n\n```\nrake cf:deploy:production\n```\n\n## `cf-deploy` makes it easy to:\n\n * Deploy your rails app with one rake command\n * Implement blue/green deployments\n * Run asset precompiles before deploying your app\n * Automate your rails deploys using jenkins, circle-ci, codeship\n\n## Getting Started\n\nThe functionality comes in the shape of generated rake tasks. You require this\ngem in your `Rakefile` and call the `.rake_tasks!` setup method.\n\n``` ruby\nrequire 'cf-deploy'\nCF::Deploy.rake_tasks!\n```\n\nBy default tasks will be created for each manifest in your `manifests/` folder.\nIf you have a `staging.yml` and `production.yml` you can now run the following\ncommands:\n\n``` sh\nbundle exec rake cf:deploy:staging\nbundle exec rake cf:deploy:production\n```\n\nYou now have rake tasks that run `cf push -f manifests/staging.yml` and\n`cf push -f manifests/production.yml`. Things start to get more exciting\nwhen you define your environments in your `Rakefile` along with their task\ndependencies just like normal rake task syntax.\n\n``` ruby\nrequire 'cf-deploy'\n\nCF::Deploy.rake_tasks! do\n  environment staging: 'assets:precompile'\n  environment production: [:clean, 'assets:precompile']\nend\n```\n\nNow when running `cf:deploy:staging` and `cf:deploy:production` the prerequisite\ntasks will be run first.\n\nThe next thing to talk about is route mapping. You can define a route in a an\nenvironment block like so:\n\n``` ruby\nrequire 'cf-deploy'\n\nCF::Deploy.rake_tasks! do\n  environment staging: 'assets:precompile' do\n    route 'example.com', 'staging'\n  end\n\n  environment production: [:clean, 'assets:precompile'] do\n    route 'example.com'\n    route 'example.com', 'www'\n    route 'example.com', 'www-origin'\n    route 'example.com', 'admin'\n  end\nend\n```\n\nAs soon as an environment with routes is pushed successfully each of it's routes\nwill be mapped to all the applications defined in the environment's manifest.\n\nAnd then things get super interesting when you start talking blue/green.\n\n## What is blue/green deployment?\n\nSimply put, blue/green deployment allows you to deploy a new version of your\napp, test it on a private URL and then direct your traffic to the new version\nwhen you are ready.\n\nYou have two applications for one environment, say production. One version is\ncalled green, the other is blue. The first time you deploy your environment\neither green or blue can be deployed. Thereafter, any changes you want to deploy\nyou deploy to the color that doesn't have your production domain pointed at it.\nYou test it on a private URL and then when you're happy you flip your domain to\npoint at that. If something then goes wrong you can then flip your domain back\nto the last working version.\n\nThis gem provides rake tasks for you to deploy using this methodology as well\nas the standard single app deployment process on a CloudFoundry provider.\n\n### An example of blue/green\n\nExamples always help and this example is probably the most common use case. You\nmight have a straight forward deployment for staging but use the blue/green\nstrategy for production. Here is what your Rakefile might look like:\n\n``` ruby\nrequire 'cf-deploy'\n\nCF::Deploy.rake_tasks! do\n  environment staging: 'assets:precompile'\n\n  environment production: 'assets:precompile' do\n    route 'example-app.io', flip: true\n    route 'example-app.io', 'www', flip: true\n    route 'example-app.io', 'www-origin', flip: true\n\n    route 'example-app.io', 'blue', blue: true\n    route 'example-app.io', 'green', green: true\n  end\nend\n```\n\nYou should also have three manifests defined:\n\n - `manifests/staging.yml`\n - `manifests/production_blue.yml`\n - `manifests/production_green.yml`\n\nWhen you run `cf:deploy:production` for the first time (assuming neither\n`production_blue.yml` or `production_green.yml` are deployed) your blue app will\nbe deployed and route setup.\n\nRunning `cf:deploy:production` thereafter will deploy which ever version isn't\ncurrently deployed. Your route(s) will not be mapped automatically this time.\nNows your chance to checkout your new deployment using an alternate route. When\nyou're happy and want to map your route across run:\n\n``` sh\nbundle exec rake cf:deploy:production:flip\n```\n\n## Installation\n\nYou need the `cf` command installed already. Grab the latest release from\nthe [CloudFoundry CLI][cli] repo on github.\n\nYou then need to install this gem in your project's `Gemfile`:\n\n``` ruby\ngem 'cf-deploy', '0.1.4'\n```\n\n### Defining CloudFoundry details in your Rakefile\n\nYou can configure some or all of your CloudFoundry details when calling\n`CF::Deploy.rake_tasks!`.\n\n``` ruby\nrequire 'cf-deploy'\n\nCF::Deploy.rake_tasks! do\n  api 'api.run.pivotal.io'\n  username 'example@example.com'\n  password 'SOMETHING'\n  organisation 'Made'\n  space 'development'\n\n  environment staging: 'assets:precompile'\n\n  environment production: 'assets:precompile' do\n    route 'yourwebsite.com', 'www', flip: true\n  end\nend\n```\n\nAll are optional. If you do not provide any you will be prompted when running\nthe rake tasks.\n\n### Defining CloudFoundry details using ENV variables\n\nInstead of defining your CloudFoundry login details in your Rakefile and\ncommitting them to your code repository you can instead provide them using\nENV variables on your command line:\n\n``` sh\nexport CF_API=api.run.pivotal.io\nexport CF_USERNAME=example@example.com\nexport CF_PASSWORD=SOMETHING\nexport CF_ORG=Made\nexport CF_SPACE=development\n```\n\nNow you can run any of the `cf-deploy` rake tasks providing you have called\n`CF::Deploy.rake_tasks!` in your `Rakefile`.\n\n## Commands\n\n### Deploying an environment\n\nIf you defined a staging environment in your Rakefile the following task will\nhave been created:\n\n```\nbundle exec rake cf:deploy:staging\n```\n\nRun this to deploy out your staging environment.\n\nAny environment you define will have a task created named `cf:deploy:#{env}`.\n\n### Deploy the next blue/green environment\n\nIf you have defined CloudFoundry manifest files matching `manifests/*_blue.yml`\nand `manifests/*_green.yml` you will be able to call `rake cf:deploy:*` without\nthe `_blue` or `_green`. For example with `production_blue.yml` and\n`production_green.yml` you can call the following:\n\n```\nbundle exec rake cf:deploy:production\n```\n\nRunning the deploy task for an env with blue and green manifests will trigger a\nlookup to see which env is currently deployed. The task will then start\ndeploying the other production color, so if green is currently deployed then\nblue will be deployed. If neither is currently deployed, blue will be deployed\nfirst.\n\nOnce deployed your routing will still be pointing to the *previous deployment*.\nIf you run the same task again, the same environment will be deployed. That is\nif green was deployed, and then you run the task, blue will be deployed, if you\nrun the task again, blue will be deployed again. This is because we work out\nthe current deployment based on where your routes are pointing and since the\ndeploy command for blue green environments doesn't map routes the current\ndeployment will not change.\n\n#### First time proviso\n\nThis isn't the case for a first time deploy. The first time you deploy your\nblue environment will be deployed and any defined routes will be mapped to all\napps defined in your blue manifest.\n\n### Switch routes over to new environment\n\nIn order to flip your routes from blue to green or vice-versa you need to run\nthe following task.\n\n```\nbundle exec rake cf:deploy:production:flip\n```\n\nThis will go ahead and map routes to whatever color the routes aren't mapped to\nand then unmap the other color. At this point your new production will be\ndeployed and live.\n\n### Turn off idle app\n\nOnce your new production has been flipped you may want to turn off your idle\napplication. There is a task for this too:\n\n```\nbundle exec rake cf:deploy:production:stop_idle\n```\n\n## Credits\n\n[![made](https://s3-eu-west-1.amazonaws.com/made-assets/googleapps/google-apps.png)][made]\n\nDeveloped and maintained by [Made Tech][made]. Key contributions:\n\n * [Luke Morton](https://github.com/DrPheltRight)\n * [Chris Blackburn](https://github.com/chrisblackburn)\n\n## License\n\nCopyright © 2014 Made Tech Ltd. It is free software, and may be\nredistributed under the terms specified in the [MIT-LICENSE][license] file.\n\n[CloudFoundry]: http://www.cloudfoundry.org/\n[Pivotal]: https://run.pivotal.io/\n[cli]: https://github.com/cloudfoundry/cli/releases\n[made]: http://www.madetech.co.uk?ref=github\u0026repo=cf-deploy\n[license]: https://github.com/madebymade/cf-deploy/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadetech%2Fcf-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadetech%2Fcf-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadetech%2Fcf-deploy/lists"}