Skip to content

Instantly share code, notes, and snippets.

@c0ldcalamari
Last active March 30, 2021 20:55
Show Gist options
  • Save c0ldcalamari/ad348cd1a7908863e4d7cc3f1e2a1ef5 to your computer and use it in GitHub Desktop.
Save c0ldcalamari/ad348cd1a7908863e4d7cc3f1e2a1ef5 to your computer and use it in GitHub Desktop.
Set up local concourse server

Blurb

This is Concourse: Quick Start, with some additional set up steps. If you're working a lot with concourse pipeline development or work with it intermittently and don't want to run around remembering how to set things up, you can quickly start and stop your concourse server with start-concourse or stop-concourse commands in your terminal.


Set up local concourse server

Prerequisite: Docker

Create a directory for your concourse server

$ mkdir concourse-server

Note the path to your directory, you will be using this path to add to your bash_profile

$ pwd

<path-to-note>/concourse-server

Change into the directory and download the docker-compose.yml

$ cd concourse-server
$ wget https://concourse-ci.org/docker-compose.yml

This will get a file that looks similar to the below -
Note: Make sure to denote the version 6.3.0, this is the version we are currently using on concourse-v6.openstax.org

version: '3'

services:
  concourse-db:
    image: postgres
    environment:
      POSTGRES_DB: concourse
      POSTGRES_PASSWORD: concourse_pass
      POSTGRES_USER: concourse_user
      PGDATA: /database

  concourse:
    image: concourse/concourse:6.3.0
    command: quickstart
    privileged: true
    depends_on: [concourse-db]
    ports: ["8080:8080"]
    environment:
      CONCOURSE_POSTGRES_HOST: concourse-db
      CONCOURSE_POSTGRES_USER: concourse_user
      CONCOURSE_POSTGRES_PASSWORD: concourse_pass
      CONCOURSE_POSTGRES_DATABASE: concourse
      CONCOURSE_EXTERNAL_URL: http://localhost:8080
      CONCOURSE_ADD_LOCAL_USER: test:test
      CONCOURSE_MAIN_TEAM_LOCAL_USER: test
      CONCOURSE_WORKER_BAGGAGECLAIM_DRIVER: overlay
      CONCOURSE_CLIENT_SECRET: Y29uY291cnNlLXdlYgo=
      CONCOURSE_TSA_CLIENT_SECRET: Y29uY291cnNlLXdvcmtlcgo=

Add the following lines to your ~./bash_profile to set your aliases: start-concourse and stop-concourse.
Save and close.

alias start-concourse="home=$PWD && cd <path-to-note>/concourse-server && docker-compose up -d && fly -t local login -c http://localhost:8080 -u test -p test && cd $home && open http://localhost:8080/
alias stop-concourse="home=$PWD && cd <path-to-note>/concourse-server && docker-compose down && cd $home"

In a new terminal window -

$ start-concourse

concourse-server_concourse-db_1 is up-to-date
concourse-server_concourse_1 is up-to-date
logging in to team 'main'


target saved

See the new concourse target you've created

$ fly targets
name               url                                team  expiry
local              http://localhost:8080              main  Sat, 27 Mar 2021 15:40:46 UTC

When you're all done using the server -

$ stop-concourse

Stopping concourse-server_concourse_1    ... done
Stopping concourse-server_concourse-db_1 ... done
Removing concourse-server_concourse_1    ... done
Removing concourse-server_concourse-db_1 ... done
Removing network concourse-server_default

📍 To Conclude:

Moving forward whenever you need to use a local concourse server the only commands you need to use will be start-concourse and stop-concourse. Instead of trying to locate the docker-compose.yml you downloaded that one time and remembering the fly command to set up a target, etc.


Encountering Bumps

If you get the following error, you can try to run the start-concourse again:

could not reach the Concourse server called local:

    Get http://localhost:8080/api/v1/info: EOF

is the targeted Concourse running? better go catch it lol

You can also delete your target and try starting concourse again:

$ fly -t local delete-target
$ start-concourse

Resources

https://concourse-ci.org/quick-start.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment