Skip to content

CircleCI-Public/cimg-base

Repository files navigation

CircleCI Logo Docker Logo Ubuntu Logo

CircleCI Convenience Images => Base

A Continous Integration focused Ubuntu Docker image built to run on CircleCI

CircleCI Build Status Software License Docker Pulls CircleCI Community Repository

InsightsSnapshot

cimg/base is an Ubuntu Docker image created by CircleCI with continuous integration builds in mind. As its name suggests, this image is designed to serve as a base image for other CircleCI Convenience Images (images prefixed with cimg/).

This image is also very useful for CircleCI users to use as a base for their own custom Docker images.

This image contains the minimum tools required to operate a build on CircleCI (such as git) as well as extremely popular and useful tools in CircleCI (such as docker).

Support Policy

The CircleCI Docker Convenience Image support policy can be found on the CircleCI docs site. This policy outlines the release, update, and deprecation policy for CircleCI Docker Convenience Images.

Table of Contents

Getting Started

This image can be used with the CircleCI docker executor. For example:

jobs:
  build:
    docker:
      - image: cimg/base:2022.09
    steps:
      - checkout
      # Whatever you want to do
      - run: sudo apt-get update && sudo apt-get install -y figlet
      - run: figlet Continuous Integration Rocks!

In the above example, the CircleCI Base Docker image is used for the primary container. More specifically, the tag 2022.09 indicates the dated version of the base image. See how tags work below for more information.

How This Image Works

This image contains the Ubuntu Linux operating system and everything needed to run most builds on CircleCI. This includes but is not limited to:

  • Git
  • Docker and Docker Compose
  • Dockerize
  • The build-essential package containing compiling tools
  • jq
  • curl, ssh, and much more

Tagging Scheme

This image has the following tagging scheme:

cimg/base:edge[-version]
cimg/base:current[-version]
cimg/base:<YYYY.MM>[-version]

edge - This image tag points to the latest version of the Base image. This tag is built from the HEAD of the main branch. The edge tag is intended to be used as a testing version of the image with the most recent changes however not guaranteed to be all that stable Software an be added for test that might actually be removed before the next monthly snapshot.. This tag is not recommended for production software.

current - This image tag points to the most recent monthly snapshot. This image should be used by projects that want a decent level of stability but would like to get occasional software updates. It is typically updated once a month. While not often, this tag can introduce breaking changes.

<YYYY.MM> - This image tag is a monthly snapshot of the image, referred to by the 4 digit year, dot, and a 2 digit month. For example 2022.01 would be the monthly snapshot tag from January 2022. This tag is intended for projects that are highly sensitive to changes and want the most deterministic builds possible. Unless absolutely necessary (for security for example), no breaking changes will be introduced as we don't rebuild a monthly snapshot.

-version - This is an optional extension to the tag to specify the version of Ubuntu to use. There can be up to two options, the current LTS and the previous LTS. As of this writing, those options would be 20.04, or 22.04. When leaving the version out, suggested, the default version will be used. The default Ubuntu version is the newest LTS version, after it has been out for 4 months. For example, Ubuntu 20.04 came out in April 2020, so it became the default version for this image in August 2020. The previous LTS version will be supported for a year after it drops out of the default slot.

Development

Images can be built and run locally with this repository. This has the following requirements:

  • local machine of Linux (Ubuntu tested) or macOS
  • modern version of Bash (v4+)
  • modern version of Docker Engine (v20.10+)

Cloning For Community Users (no write access to this repository)

Fork this repository on GitHub. When you get your clone URL, you'll want to add --recurse-submodules to the clone command in order to populate the Git submodule contained in this repo. It would look something like this:

git clone --recurse-submodules <my-clone-url>

If you missed this step and already cloned, you can just run git submodule update --recursive to populate the submodule. Then you can optionally add this repo as an upstream to your own:

git remote add upstream https://github.com/CircleCI-Public/cimg-base.git

Cloning For Maintainers ( you have write access to this repository)

Clone the project with the following command so that you populate the submodule:

git clone --recurse-submodules git@github.com:CircleCI-Public/cimg-base.git

Generating Dockerfiles

The Dockerfile in the Ubuntu version directory (i.e. 20.04/) is already in a state to be built if you want to build a new version of this image. Running docker build in this directory will be enough.

Changes to this image should occur in the Dockerfile.template file and then using the gen-dockerfiles.sh script, a new Dockerfile will be built. For example, you would run the following from the root of the repo:

./shared/gen-dockerfiles.sh 20.04 22.04

The generated Dockerfile will be located at ./20.04/Dockefile and ./22.04/Dockerfile. To build the first image locally and try it out, you can run the following:

cd 20.04
docker build -t test/base:20.04 .
docker run -it test/base:20.04 bash

While CircleCI will only be publishing LTS versions of Ubuntu (such as 20.04 or 22.04), you are free to swap out the version number with something newer for your own personal use.

Building the Dockerfiles

To build the Docker images locally as this repository does, run the build-images.sh script:

./build-images.sh

This script needs to be run after generating the Dockerfiles first. When releasing proper images for CircleCI, this script is run from a CircleCI pipeline and not locally.

Publishing Official Images (for Maintainers only)

The individual scripts (above) can be used to create the correct files for an image, and then added to a new git branch, committed, etc. stage and edge releases are completely automated as in the monthly snapshots. The release script is included to make this process easier for LTS updates. To make an updated LTS release for this image, you would run the following from the repo root:

./shared/release.sh 20.04

This will automatically create a new Git branch, generate the Dockerfile(s), stage the changes, commit them, and push them to GitHub. All that would need to be done after that is:

  • wait for build to pass on CircleCI
  • review the PR
  • merge the PR

The main branch build will then publish a release. edge will be updated immediately with the LTS change occurring during the next monthly release.

Incorporating Changes

How changes are incorporated into this image depends on where they come from.

build scripts - Changes within the ./shared submodule happen in its own repository. For those changes to affect this image, the submodule needs to be updated. Typically like this:

cd shared
git pull
cd ..
git add shared
git commit -m "Updating submodule for foo."

Base specific changes - Editing the Dockerfile.template file in this repo will modify the Go image, specifically. Don't forget that to see any of these changes locally, the gen-dockerfiles.sh script will need to be run again (see above).

Fixing a Monthly Snapshot

You can respin (re-release) a monthly snapshot where there's a serious bug or security issue. This can be done by tagging a commit as monthly. This will re-create the monthly snapshot for the current month.

Contributing

We encourage issues and pull requests against this repository.

Please check out our contributing guide which outlines best practices for contributions and what you can expect from the images team at CircleCI.

Additional Resources

CircleCI Docs - The official CircleCI Documentation website. CircleCI Configuration Reference - From CircleCI Docs, the configuration reference page is one of the most useful pages we have. It will list all of the keys and values supported in .circleci/config.yml. Docker Docs - For simple projects this won't be needed but if you want to dive deeper into learning Docker, this is a great resource.

License

This repository is licensed under the MIT license. The license can be found here.