Install Concourse CI on Ubuntu 20.04 Using Docker

By Chandrashekhar Fakirpure

Updated on Feb 01, 2024

In this article, we'll learn how to install Concourse CI on Ubuntu 20.04 Using Docker.

Concourse is an open-source continuous thing-doer. Continuous integration (CI) is the practice of automating the integration of code changes from multiple contributors into a single software project.  Concourse is  built on the simple mechanics of resources, tasks, and jobs, Concourse presents a general approach to automation that makes it great for CI/CD.

Prerequisites

  • A Ubuntu 20.04 install dedicated server.
  • A normal user with administrative privileges.
  • Add 'A' DNS record of the domain you wish to use.

Install Concourse CI on Ubuntu 20.04

1. Keep the server updated

Always keep the server updated.

# apt update -y && apt upgrade -y

2. Install Docker

First, we'll install Docker and Docker Compose, in order to create a containers for Concourse and the database (PostgreSQL).

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

3. Install Concourse

Before we install Concourse, we need to download docker-compose.yml file from official link. It is the set of instructions for containers to create and start and their configuration.

# curl -LO https://concourse-ci.org/docker-compose.yml
# vim docker-compose.yml

Here, we need to do two modifications primarily. Make sure to change

http://localhost:8080 change to https://ci.example.com

CONCOURSE_ADD_LOCAL_USER: test:test change to  CONCOURSE_ADD_LOCAL_USER: myuser:mypass

You can modify other options as per your requirements.

Now, start the containers and remove docker-compose.yml file.

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

4. 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

5. 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

You can access Concourse in the web browser using your server IP and port 8080.

6. Install Nginx and Certbot

To access Concourse over the website, we need to install and configure Nginx. Use following command to install Nginx and Certbot.

# sudo apt install -y nginx certbot

After the installation gets completed, deploy a SSL certificate using following command:

# sudo certbot certonly --webroot -w /var/www/html -d ci.example.com

Note: Replace ci.example.com with your domain name.

For auto renewal of the SSL certificate, we need to add cron job. Use following commands:

# crontab -e

Add following line

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

Save and exit

Now, let's create a configuration file for Concourse in Nginx. Use following command to create a .conf file

# sudo vim /etc/nginx/sites-available/concourse.conf

Add following lines:

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

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

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

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

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

Note: Replace ci.example.com with your domain name.

Create a symbolic link using following command:

# ln -s /etc/nginx/sites-available/concourse.conf /etc/nginx/sites-enabled/

Once done, test the Nginx configuration files and restart Nginx service.

# nginx -t
# systemctl restart nginx

The installation has been completed successfully. Navigate to browser and access with Concourse with your domain name.

In this article, we've seen how to install Concourse CI on Ubuntu 20.04 Using Docker.