Choose package repo dynamically
1 file changed
tree: 2f3e511517e45b8b4d5b90570db5b4ddbac8fa2d
  1. .github/
  2. bin/
  3. dockerfiles/
  4. files/
  5. .dockerignore
  6. .gitignore
  7. build.sh
  8. freebsd-jenkins-setup.md
  9. pull-all-couchdbdev-docker
  10. README.md
  11. TODO.md
README.md

CouchDB Continuous Integration (CI) support repo

The main purpose of this repository is to provide scripts that:

  • Install the necessary build-time dependencies for CouchDB on a number of platforms, either inside or outside of a container or VM
  • Build Docker containers with those dependencies necessary to build binary JavaScript (SpiderMonkey 1.8.5) packages
  • Build Docker containers with all dependencies necessary to build CouchDB, including Erlang and JavaScript

It intends to cover a range of both operating systems (Linux, macOS, BSD, Windows) and Erlang versions (17.x, 18.x, 19.x, etc.)

These images are used by Apache Jenkins CI to build CouchDB with every checkin to main, 3.x, a release branch (e.g., 2.3.0), or an open Pull Request. CouchDB's CI build philosophy is to validate CouchDB against different Erlang versions with each commit to a Pull Request, and to validate CouchDB against different OSes and architectures on merged commits to main, 3.x, and release branches. Where possible, Jenkins also auto-builds convenience binaries or packages. The eventual goal is that these auto-built binaries/packages/Docker images will be auto-pushed to our distribution repos for downstream consumption.

Supported Configurations (updated 2021-03-11)

OS / distroVersionErlang VersionsArchitecturesDocker?
debianstretch19.3.6, 20.3.8.25x86_64, arm64v8:heavy_check_mark:
debianbuster20.3.8.25x86_64, arm64v8:heavy_check_mark:
ubuntubionic20.3.8.25x86_64:heavy_check_mark:
centos620.3.8.25x86_64:heavy_check_mark:
centos720.3.8.25x86_64:heavy_check_mark:
centos820.3.8.25x86_64:heavy_check_mark:
freebsd11.xdefaultx86_64:x:
freebsd12.0defaultx86_64:x:

...with support now for any arbitrary Erlang version!


Docker

For those OSes that support Docker, we run builds inside of Docker containers. These containers are built using the build.sh command at the root level.

Authenticating to Docker Hub

  1. You need a Docker Cloud account with access to the apache organization to upload new images. Ask the CouchDB PMC for assistance with this.
  2. export DOCKER_ID_USER="username"
  3. docker login -u "username" and enter your password.

Building a “platform image”

The platform images include all of the build dependencies necessary to build and full test CouchDB on a given OS/version/architecture combination.

Build a platform image with:

./build.sh platform <distro>-<version>

Overriding the Erlang, Elixir or Node version

We want to generate a rebar binary compatible with all versions of Erlang we support. If we do this on too new a version, older Erlangs won't recognize it. So we always keep an image around with that version.

On the other hand, some OSes won't run older Erlangs because of library changes, so you need to override that environment variable.

Just specify on the command line any of the ERLANGVERSION, NODEVERSION, or ELIXIRVERSION environment variables:

NODEVERSION=8 ELIXIRVERSION=v1.6.1 ERLANGVERSION=17.5.3 ./build.sh platform debian-jessie

The tool also recognizes a special ERLANGVERSION=all value for the debian-buster platform. This builds the lowest, default, and highest versions of Erlang using the kerl build system, and installs them to /usr/local/kerl for activation before builds. This version is intended for use in standard CI runs, such as for pull requests.

Building a cross-architecture Docker image

We can use Docker‘s Buildx plugin to generate multi-architecture container images with a single command invocation. Docker Desktop ships with buildx support, but you’ll need to create a new builder to use it:

docker buildx create --use

Then, add the --platform flag to spin up parallel builders for each desired architecture. For example:

buildargs="--platform linux/amd64,linux/arm64,linux/ppc64le --push" ./build.sh platform debian-bullseye

will build and upload a new multi-arch container image to the registory. Currently docker images can only accept single-platform images, so this is one downside of the simplified build approach. Omitting the --push option will just leave the build result in the build cache, which isn't terribly useful.

Publishing a container

If you built a single-architecture container image and did not supply --push as a build arg to upload it automatically you can upload the image using

./build.sh platform-upload <distro>-<version>

Useful things you can do

Full build.sh options

./build.sh <command> [OPTIONS]

Recognized commands:
  clean <plat>          Removes all images for <plat>.
  clean-all             Removes all images for all platforms.

  platform <plat>       Builds the image for <plat> with Erlang & JS support.
  platform-all          Builds all images with Erlang and JS support.
  *platform-upload      Uploads the couchdbdev/*-erlang-* images to Docker Hub.
  *platform-upload-all  Uploads all the couchdbdev/*-erlang-* images to Docker.

  couch <plat>          Builds and tests CouchDB for <plat>.
  couch-all             Builds and tests CouchDB on all platforms.

  Commands marked with * require appropriate Docker Hub credentials.

Interactively working in a built container

After building the image as above:

docker run -it couchdbdev/<tag>

where <tag> is of the format <distro>-<version>-<type>, such as debian-stretch-erlang-19.3.6.

Running the CouchDB build in a published container

./build.sh couch <distro>-<version>

Building SpiderMonkey 1.8.5 convenience packages

This is only needed if a platform does not have a supported SpiderMonkey library. As of April 2021, this is no currently supported platform.

First, build the ‘base’ image with:

./build.sh base <distro>-<version>

After building the base image as above, head over to the apache/couchdb-pkg repository and follow the instructions there.

Adding support for a new release/platform/architecture

  1. Update the build scripts in the bin/ directory to install the dependencies correctly on your new OS/version/platform. Push a PR with these changes.
  2. Copy and customize an appropriate Dockerfile in the dockerfiles directory for your new OS.
  3. If a supported SpiderMonkey library is not available on the target platform, build a base image using ./build.sh base <distro>-<version>. Solve any problems with the build process here.
  4. Using the apache/couchdb-pkg repository, validate you can build the JS package. Fix any problems in that repo that arise and raise a new PR. Open a new issue on that PR requesting that the JS packages be made available through the CouchDB repository/download infrastructure.
  5. Build a full platform image with ./build.sh platform <distro>-<version>. Solve any problems with the build process here.
  6. Submit a PR against the apache/couchdb repository, adding the new platform to the top level Jenkinsfile. Ask if you need help.

Other platforms

We are eager for contributions to enhance the build scripts to support setting up machines with the necessary build environment for:

as well as alternative architectures for the already supported image types (armhf, ppc64le, s390x, sparc, etc).

We know that Docker won't support some of these, but we should be able to at least expand the install scripts for all of these platforms.

Background

See: