How to Install and Configure Concourse CI on Ubuntu 20.04

Updated on August 4, 2021
How to Install and Configure Concourse CI on Ubuntu 20.04 header image

Introduction

According to its documentation, Concourse is "a pipeline-based continuous thing-doer."

Continuous Integration (CI) is a DevOps software development practice that enables developers to merge code into the shared repository many times per day. Concourse CI performs continuous integration tasks such as automatic builds and tests for each deployment.

This guide explains how to install Concourse CI on Ubuntu. When following this guide, replace all instances of ci.example.org with your server's fully-qualified domain name.

Components

  • ATC: Web UI, API, pipeline scheduling.
  • TSA: custom SSH server for registering workers with ATC.
  • Workers:
    • Garden: container runtime, handles running containers remotely.
    • Baggageclaim: cache and artifact management.
  • Fly: CLI interface for ATC, used for configuring pipelines.

Prerequisites

  • A Vultr Ubuntu 20.04 instance.
  • A sudo user.
  • A fully-qualified DNS "A" record that points to your server's IP address in DNS.

1. Install Docker

Install Docker and Docker Compose to create containers for Concourse and the database (PostgreSQL).

$ sudo apt install -y docker.io docker-compose

2. Install Concourse

Download the docker-compose.yml file that outlines what containers to create and start and their configuration.

$ curl -LO https://concourse-ci.org/docker-compose.yml
$ nano docker-compose.yml

In the docker-compose.yml file, make sure to change http://localhost:8080 to https://ci.example.org, replacing example.org with your domain name.

Other options, such as credentials, are also configurable in this file. Once done, save and exit the file.

Now, start the containers.

$ sudo docker-compose up -d
$ rm -f docker-compose.yml

3. Install Fly CLI

Download the Fly CLI binary and make it executable.

$ sudo curl -o /usr/local/bin/fly "http://localhost:8080/api/v1/cli?arch=amd64&platform=linux"
$ sudo chmod 755 /usr/local/bin/fly

4. Test Fly CLI

Test to make sure that the Fly CLI was installed and can connect to the ATC server.

$ fly -t tutorial login -c http://localhost:8080 -u test -p test

5. Nginx Reverse Proxy

Install Nginx and Certbot. This will allow a secure HTTPS connection to the server once configured.

$ sudo apt install -y nginx certbot

Get an HTTPS certificate for your domain. This requires that your domain points towards the IP of your Vultr instance. Consult your domain provider for instructions on how to add an A record for your instance. Make sure to replace example.org with your domain name.

$ sudo certbot certonly --webroot -w /var/www/html -d ci.example.org

Enable auto-renew for Certbot by editing the Crontab file.

$ crontab -e

Once the file is opened, add the following line.

30 5 * * * /usr/bin/certbot renew

Once done, save and exit the file.

Now, configure the Nginx virtual host to proxy traffic for the domain to the Concourse ATC server and to use the HTTPS certificate.

$ sudo nano /etc/nginx/sites-enabled/concourse

Once the file is opened, add the following lines. Replace ci.example.org with your server's fully-qualified domain name in four places.

server {
    listen 80;
    listen [::]:80;
    server_name ci.example.org;

    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name ci.example.org;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_certificate /etc/letsencrypt/live/ci.example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ci.example.org/privkey.pem;

    location / {
        proxy_pass http://localhost:8080;
    }
}

Once done, exit and save the file. Now, reload the Nginx configuration.

$ sudo systemctl reload nginx

Conclusion

The web UI should now be available at your server's domain name. For example: https://ci.example.org

More Information

See the Concourse documentation for more information.