This is an example of a simple website that you can host on your cloud foundry environment, using Concourse for automated deployments. Just check in your code and let Concourse take care of the rest.
- A Cloud Foundry environment you can use
- A Concourse environment you can use
- The Concourse Fly CLI installed. You can install from your concourse home page, see the icons in the lower right corner.
-
Fork the repo to your own github account
-
Clone the repo to your workstation
cd
git clone https://github.com/YOUR-GITHUB-ACCOUNT/website-demo
cd website-demo
- Edit the pipeline.yml file, and replace
mjeffries-pivotal
with YOUR-GITHUB-ACCOUNT under theresource-web-app
resource. Also note that the pipeline has 2 resources, one for github, and one for Cloud Foundry. There is one job (job-deploy-app
) which uses the resources to get your latest website content and deploy it to Cloud Foundry.
---
resources:
- name: resource-web-app
type: git
source:
uri: https://github.com/mjeffries-pivotal/website-demo.git
- name: resource-deploy-web-app
type: cf
source:
api: {{cf-api}}
username: {{cf-username}}
password: {{cf-password}}
organization: {{cf-organization}}
space: {{cf-space}}
skip_cert_check: true
jobs:
- name: job-deploy-app
serial: true
plan:
- {get: resource-web-app, trigger: true}
- put: resource-deploy-web-app
params:
manifest: resource-web-app/website/manifest.yml
path: resource-web-app/website
- Create a credentials.yml file with the following contents in the
website-demo
directory. Replace the placeholders with your cloud foundry environment information (runcf target
). Be sure to include credentials.yml in your .gitignore file in the website-demo directory so you don't upload it when you commit your changes.
cf-api: https://YOUR-CF-API-ENDPOINT
cf-username: YOUR-CF-USERID
cf-password: YOUR-CF-PASSWORD
cf-organization: YOUR-CF-ORG
cf-space: YOUR-CF-SPACE
- Login to concourse using the Fly CLI. You'll be prompted for your concourse userid and password. If you have been assigned to a team, include
-n TEAM_NAME
when you login. You can use any value for YOUR_CONCOURSE-TARGET, such asdemo
orlab
, you'll just need to include the same value in subsequentfly
commands.
fly -t YOUR-CONCOURSE-TARGET login -c CONCOURSE_URL -n TEAM_NAME
- Create the pipeline
fly set-pipeline --target YOUR-CONCOURSE-TARGET --config pipeline.yml --pipeline deploy-website-demo --non-interactive --load-vars-from ./credentials.yml
fly unpause-pipeline --target YOUR-CONCOURSE-TARGET --pipeline deploy-website-demo
-
To see your pipeline in concourse, copy the URL from the output of the command above to your browser. Login using same userid/password you did for the fly CLI.
-
Click on the job
job-deploy-app
, then kick off a manual build by clicking on the plus sign at the upper right corner of the page. The build should start after a few seconds. Look at the build output to see your website pushed to cloud foundry.
-
Now you're ready to start automating. Edit the
index.html
file to change the text or color, then commit and sync your changes. Refresh your Concourse page and within a minute or so you should see a new build kick off. Get the URL for your app from the output of the build, and bring it up in a browser. The website should have the changes you just made. -
Now you just need to check in your code, and Concourse will handle your deployment to Cloud Foundry.
-
When you're done, you can destroy the pipeline:
fly -t YOUR-CONCOURSE-TARGET destroy-pipeline -p deploy-website-demo
- Explore the fly CLI.