!!! Concourse

[{TableOfContents }]

!! Resources

* [Home|https://concourse.ci/]

!! Installing

I opted for the Docker install, see [https://concourse.ci/docker-repository.html]  

Created and cd'ed to /home/metksem/concourse.
Created and ran the following script to generate the keys:
%%prettify
{{{
#!/bin/bash
mkdir -p keys/web keys/worker

ssh-keygen -t rsa -f ./keys/web/tsa_host_key -N ''
ssh-keygen -t rsa -f ./keys/web/session_signing_key -N ''

ssh-keygen -t rsa -f ./keys/worker/worker_key -N ''

cp ./keys/worker/worker_key.pub ./keys/web/authorized_worker_keys
cp ./keys/web/tsa_host_key.pub ./keys/worker
}}}
%%

Created this docker-compose.yml file:


%%collapsebox
__docker-compose.yml__ 

%%prettify
{{{
concourse-db:
  image: postgres:9.5
  environment:
    POSTGRES_DB: concourse
    POSTGRES_USER: concourse
    POSTGRES_PASSWORD: changeme
    PGDATA: /database

concourse-web:
  image: concourse/concourse
  links: [concourse-db]
  command: web
  ports: ["8080:8080"]
  volumes: ["./keys/web:/concourse-keys"]
  environment:
    CONCOURSE_BASIC_AUTH_USERNAME: concourse
    CONCOURSE_BASIC_AUTH_PASSWORD: changeme
    CONCOURSE_EXTERNAL_URL: "${CONCOURSE_EXTERNAL_URL}"
    CONCOURSE_POSTGRES_DATA_SOURCE: |-
      postgres://concourse:changeme@concourse-db:5432/concourse?sslmode=disable

concourse-worker:
  image: concourse/concourse
  privileged: true
  links: [concourse-web]
  command: worker
  volumes: ["./keys/worker:/concourse-keys"]
  environment:
    CONCOURSE_TSA_HOST: concourse-web
}}}
%%
%%

Fire up the thing with {{docker-compose up}} and find out the IP address of the docker container with {{docker inspect concourse_concourse-web_1|grep IPAd
}} \\
And point your browser at the [minimalistic UI|http://172.17.0.3:8080] , login with user {{concourse}} and password {{changeme}}.\\
From the UI you can download the [fly|https://concourse.ci/fly-cli.html] cli :

%%collapsebox
__fly cli__
{{{
➜  concourse ~/Downloads/fly --help
error: Usage:
  fly [OPTIONS] <command>

Application Options:
  -t, --target=  Concourse target name
  -v, --version  Print the version of Fly and exit

Help Options:
  -h, --help     Show this help message

Available commands:
  abort-build       Abort a build (aliases: ab)
  builds            List builds data (aliases: bs)
  check-resource    Check a resource (aliases: cr)
  checklist         Print a Checkfile of the given pipeline (aliases: cl)
  containers        Print the active containers (aliases: cs)
  destroy-pipeline  Destroy a pipeline (aliases: dp)
  destroy-team      Destroy a team and delete all of its data (aliases: dt)
  execute           Execute a one-off build using local bits (aliases: e)
  expose-pipeline   Make a pipeline publicly viewable (aliases: ep)
  get-pipeline      Get a pipeline's current configuration (aliases: gp)
  help              Print this help message
  hide-pipeline     Hide a pipeline from the public (aliases: hp)
  hijack            Execute a command in a container (aliases: intercept, i)
  login             Authenticate with the target (aliases: l)
  pause-job         Pause a job (aliases: pj)
  pause-pipeline    Pause a pipeline (aliases: pp)
  pause-resource    Pause a resource (aliases: pr)
  pipelines         List the configured pipelines (aliases: ps)
  rename-pipeline   Rename a pipeline (aliases: rp)
  set-pipeline      Create or update a pipeline's configuration (aliases: sp)
  set-team          Create or modify a team to have the given credentials (aliases: st)
  sync              Download and replace the current fly from the target (aliases: s)
  targets           List saved targets (aliases: ts)
  trigger-job       Start a job in a pipeline (aliases: tj)
  unpause-job       Unpause a job (aliases: uj)
  unpause-pipeline  Un-pause a pipeline (aliases: up)
  unpause-resource  Unpause a resource (aliases: ur)
  volumes           List the active volumes (aliases: vs)
  watch             Stream a build's output (aliases: w)
  workers           List the registered workers (aliases: ws)
}}}
%%

First move the fly binary to /usr/local/bin and chmod 755 it.

!! Using concourse

You basically do everything with the {{fly}} cli.\\
First login and then show targets:
{{{
➜  concourse fly -t lite login --concourse-url=http://172.17.0.3:8080
username: concourse
password: 

target saved
➜  concourse fly targets
name  url                     expiry                       
lite  http://172.17.0.3:8080  Sun, 11 Dec 2016 13:38:53 UTC
}}}

!!! Create pipeline

Save the following in hello.yml:

%%prettify
{{{
jobs:
- name: hello-world
  plan:
  - task: say-hello
    config:
      platform: linux
      image_resource:
        type: docker-image
        source: {repository: ubuntu}
      run:
        path: echo
        args: ["Hello, world!"]
}}}
%%

And create the pipeline with {{pipelines fly --target=lite set-pipeline --pipeline=hello-world --config=hello.yml}} : 
%%prettify
{{{
➜  pipelines fly --target=lite set-pipeline --pipeline=hello-world --config=hello.yml
jobs:
  job hello-world has been added:
    name: hello-world
    plan:
    - task: say-hello
      config:
        platform: linux
        image_resource:
          type: docker-image
          source:
            repository: ubuntu
        run:
          path: echo
          args:
          - Hello, world!
          dir: ""
    
apply configuration? [yN]: y
pipeline created!
you can view your pipeline here: http://172.17.0.3:8080/teams/main/pipelines/hello-world

the pipeline is currently paused. to unpause, either:
  - run the unpause-pipeline command
  - click play next to the pipeline in the web ui
}}}
%%