Skip to content

Commit

Permalink
Add Jammy support
Browse files Browse the repository at this point in the history
  • Loading branch information
mamercad committed Feb 19, 2024
1 parent ab34714 commit fa8f3e5
Show file tree
Hide file tree
Showing 9 changed files with 467 additions and 313 deletions.
31 changes: 16 additions & 15 deletions .circle/docker-compose2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

set -e
# Source the build environment defintion (details in buildenv.sh)
# shellcheck disable=SC1090
. ~/.buildenv

set -x
Expand All @@ -18,31 +19,31 @@ case "$1" in
# containers running from the previous cached build
clean)
echo Cleaning cached Docker containers which could be there from the previous build ...
docker-compose -f docker-compose.circle2.yml -f docker-compose.override.yml rm -v --stop --force || true
docker compose -f docker-compose.circle2.yml -f docker-compose.override.yml rm -v --stop --force || true
;;
# Perform fake command invocation, technically provides images "pull" phase.
pull)
echo Pulling dependent Docker images for $2 ...
docker-compose -f docker-compose.circle2.yml -f docker-compose.override.yml pull --include-deps $2
echo "Pulling dependent Docker images for $2 ..."
docker compose -f docker-compose.circle2.yml -f docker-compose.override.yml pull --include-deps $2
;;
build)
echo Starting Packages Build for $2 ...
docker-compose -f docker-compose.circle2.yml -f docker-compose.override.yml run \
-e ST2_CHECKOUT=${ST2_CHECKOUT} \
-e ST2_GITURL=${ST2_GITURL} \
-e ST2_GITREV=${ST2_GITREV} \
-e ST2_GITDIR=${ST2_GITDIR} \
-e ST2PKG_VERSION=${ST2PKG_VERSION} \
-e ST2PKG_RELEASE=${ST2PKG_RELEASE} \
echo "Starting Packages Build for $2 ..."
docker compose -f docker-compose.circle2.yml -f docker-compose.override.yml run \
-e ST2_CHECKOUT="${ST2_CHECKOUT}" \
-e ST2_GITURL="${ST2_GITURL}" \
-e ST2_GITREV="${ST2_GITREV}" \
-e ST2_GITDIR="${ST2_GITDIR}" \
-e ST2PKG_VERSION="${ST2PKG_VERSION}" \
-e ST2PKG_RELEASE="${ST2PKG_RELEASE}" \
-e ST2_PACKAGES="${ST2_PACKAGES}" \
-e ST2_CIRCLE_URL=${CIRCLE_BUILD_URL} \
-e ST2_CIRCLE_URL="${CIRCLE_BUILD_URL}" \
$2 build
;;
test)
[ "$TESTING" = 0 ] && { echo "Omitting Tests for $2 ..." ; exit 0; }
echo Starting Tests for $2 ...
docker-compose -f docker-compose.circle2.yml -f docker-compose.override.yml run \
echo "Starting Tests for $2 ..."
docker compose -f docker-compose.circle2.yml -f docker-compose.override.yml run \
-e ST2_PACKAGES="${ST2_PACKAGES}" \
$2 test
"$2" test
;;
esac
6 changes: 3 additions & 3 deletions .circle/packagecloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function main() {
fi
;;
*)
echo $"Usage: deploy {focal|el6|el8} /tmp/st2-packages"
echo $"Usage: next-revision {focal|el6|el8} 0.14dev st2"
echo $"Usage: deploy {focal|jammy|el8} /tmp/st2-packages"
echo $"Usage: next-revision {focal|jammy|el8} 0.14dev st2"
exit 1
esac
}
Expand Down Expand Up @@ -230,7 +230,7 @@ function get_pkg_os() {
PKG_OS_VERSION=$PKG_OS
PKG_TYPE="deb"
;;
warty|hoary|breezy|dapper|edgy|feisty|gutsy|hardy|intrepid|jaunty|karmic|lucid|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|bionic|focal)
warty|hoary|breezy|dapper|edgy|feisty|gutsy|hardy|intrepid|jaunty|karmic|lucid|maverick|natty|oneiric|precise|quantal|raring|saucy|trusty|utopic|vivid|wily|xenial|bionic|focal|jammy)
PKG_OS_NAME=ubuntu
PKG_OS_VERSION=$PKG_OS
PKG_TYPE="deb"
Expand Down
31 changes: 23 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 2
jobs:
# Build & Test st2 packages
packages:
parallelism: 2
parallelism: 3
# 4CPUs & 8GB RAM CircleCI machine
# sadly, it doesn't work with 'setup_remote_docker'
resource_class: large
Expand All @@ -17,7 +17,7 @@ jobs:
- image: circleci/python:3.8
working_directory: ~/st2-packages
environment:
DISTROS: "focal el8"
DISTROS: "focal jammy el8"
BASH_ENV: ~/.buildenv
# These should be set to an empty string, so that st2cd prep tasks are able to replace these
# with real gitrevs during releases. Note that they are commented out, so that they do not interfere
Expand All @@ -26,10 +26,25 @@ jobs:
# ST2_GITREV: ""
steps:
- checkout
- run:
name: Install latest Docker Compose V2
command: |
set -x
export CODENAME=$(source /etc/os-release && echo "$VERSION_CODENAME")
export DISTRO=$(source /etc/os-release && echo "$ID")
export ARCH=$(dpkg --print-architecture)
# get gpg key for download.docker
curl -fsSL https://download.docker.com/linux/${DISTRO}/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/download.docker.gpg
# set source list
sudo tee <<<"deb [arch=${ARCH}] https://download.docker.com/linux/${DISTRO} ${CODENAME} stable" /etc/apt/sources.list.d/download.docker.list
# update package list
sudo apt update
# install docker CLI and Docker Compose v2
sudo apt install docker-ce-cli docker-compose-plugin
- setup_remote_docker:
reusable: true # default - false
exclusive: true # default - true
version: 19.03.14
# reusable: true # default - false
# exclusive: true # default - true
version: docker24
- run:
name: Ensure installation scripts are synced with their templates
command: make .generated-files-check
Expand All @@ -38,7 +53,7 @@ jobs:
command: |
set -x
docker --version
docker-compose --version
docker compose --version
- run:
name: Initialize packages Build Environment
command: |
Expand Down Expand Up @@ -73,7 +88,7 @@ jobs:
command: |
# Create necessary directories
mkdir -p ~/st2-packages/build/${DISTRO}/log/
# Run the build
.circle/docker-compose2.sh build ${DISTRO}
Expand Down Expand Up @@ -116,7 +131,7 @@ jobs:
- image: circleci/ruby:2.7
working_directory: /tmp/deploy
environment:
- DISTROS: "focal el8"
- DISTROS: "focal jammy el8"
steps:
- attach_workspace:
at: .
Expand Down
98 changes: 49 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

## Highlights

- **Docker based**. Leveraging docker it's possible to deliver packages for any OS distro in a fast and reliable way.
- [Rake](https://github.com/ruby/rake) + [sshkit](https://github.com/capistrano/sshkit)-based execution enables easy configuration via **simple DSL** and brings **parallel task processing** out of the box.
- **Test-driven workflow**. Artifacts built are not only available for any enabled OS distro but at the same time tested on a bunch of platforms, providing feedback such as can be installed, services can start up, operations can be executed etc.
- **Docker based**. Leveraging docker it's possible to deliver packages for any OS distro in a fast and reliable way.
- [Rake](https://github.com/ruby/rake) + [sshkit](https://github.com/capistrano/sshkit)-based execution enables easy configuration via **simple DSL** and brings **parallel task processing** out of the box.
- **Test-driven workflow**. Artifacts built are not only available for any enabled OS distro but at the same time tested on a bunch of platforms, providing feedback such as can be installed, services can start up, operations can be executed etc.

## Overview

Packages build environment is a *multi-container docker* application defined and managed with [docker-compose](https://github.com/docker/compose). It consists of four types of containers:
Packages build environment is a _multi-container docker_ application defined and managed with [docker-compose](https://github.com/docker/compose). It consists of four types of containers:

- **Packaging runner** (https://quay.io/stackstorm/packagingrunner) - the main entry point, package build and test processing controller container.
- **Packaging build** (https://hub.docker.com/r/stackstorm/packagingbuild/) - container where actual `.deb`/`.rpm` artifacts build takes place. It's used to bring up the build environment specific for OS distro. This means that different containers are available such as *packagingbuild:rocky8*, *packagingbuild:focal* correspondingly for RockyLinux 8 and Ubuntu Focal.
- **Packaging test** (https://hub.docker.com/r/stackstorm/packagingtest/) - containers where built artifacts are tested, i.e. *artifacts are installed, configuration is written and tests are performed*.
- **Services** - these are different containers required for testing such as *rabbitmq and mongodb*
- **Packaging runner** (https://quay.io/stackstorm/packagingrunner) - the main entry point, package build and test processing controller container.
- **Packaging build** (https://hub.docker.com/r/stackstorm/packagingbuild/) - container where actual `.deb`/`.rpm` artifacts build takes place. It's used to bring up the build environment specific for OS distro. This means that different containers are available such as _packagingbuild:rocky8_, _packagingbuild:focal_, _packagingbuild:jammy_, correspondingly for RockyLinux 8, Ubuntu Focal, and Ubuntu Jammy.
- **Packaging test** (https://hub.docker.com/r/stackstorm/packagingtest/) - containers where built artifacts are tested, i.e. _artifacts are installed, configuration is written and tests are performed_.
- **Services** - these are different containers required for testing such as _rabbitmq and mongodb_

`Dockerfiles` sources are available at [StackStorm/st2-dockerfiles](https://github.com/stackstorm/st2-dockerfiles).

Expand All @@ -29,11 +29,11 @@ It's very simple to invoke the whole build-test pipeline. First just make sure t

```shell
# (Optional) First clean out previous build containers
docker-compose kill
docker-compose rm -f
docker compose kill
docker compose rm -f

# To build packages for ubuntu focal (--rm will wipe packaging runner container. All others will remain active).
docker-compose run --rm focal
# To build packages for ubuntu jammy (--rm will wipe packaging runner container. All others will remain active).
docker compose run --rm jammy
```

Execution takes a while, so grab a cup of tea or coffee and wait until it finishes. When build and test processes succeed, you'll find the StackStorm packages in `/tmp/st2-packages` on your host machine:
Expand All @@ -47,38 +47,39 @@ ls -l1 | grep ".deb$"

After the build and test stages are finished all docker containers remain active, so you are welcome to do more in-depth testing if desired. To do so simply run:

```
```shell
docker ps
# Find the required testing container
# In our case it will be st2packages_focaltest_1
# In our case it will be st2packages_jammytest_1

# Simply exec to docker
docker exec -it st2packages_focaltest_1 bash
docker exec -it st2packages_jammytest_1 bash
```

Once done, you are inside the testing environment where all services are up and running. Don't forget to do (after exec):

```
```shell
export TERM=xterm
```

At this point you can do any manual testing which is required.

# Vagrant based build and test

In order to build, package, install and test ST2 in an isolated Vagrant VM, run the following:

```
```shell
vagrant up $TARGET
```

Where `$TARGET` is one of `focal`, or `el8`. If you are using `el8`, comment
Where `$TARGET` is one of `focal`, `jammy`, or `el8`. If you are using `el8`, comment
out the `vm_config.vm.provision :docker` line in the Vagrantfile. There is logic in `setup-vagrant.sh`
to install docker in `el8`.

The following steps are run while provisioning the Vagrant VM:

1. Install `docker` and `docker-compose`.
2. Run `docker-compose run --rm $TARGET` to build, test and package ST2 as described in prior
2. Run `docker compose run --rm $TARGET` to build, test and package ST2 as described in prior
sections.
3. Install the packages built in step 2, unless the host `$ST2_INSTALL` environment variable is set to
a value other than `yes`.
Expand All @@ -90,66 +91,65 @@ consider allowing the host to provide existing ST2 packages, and install/self-ch
Vagrant VM.

To specify the ST2 source URL and REV (i.e., branch), use `ST2_GITURL` and `ST2_GITREV` environment
variables on the host prior to provisioning the VM.
variables on the host prior to provisioning the VM.

Prior to running `st2-self-check`, the required auth token is generated using `st2 auth`. If necessary,
you can change the default username and password passed to `st2 auth`. To do this, set the `ST2USER`
Prior to running `st2-self-check`, the required auth token is generated using `st2 auth`. If necessary,
you can change the default username and password passed to `st2 auth`. To do this, set the `ST2USER`
and `ST2PASSWORD` environment variables on the host prior to provisioning the VM. The default values
are `st2admin` and `Ch@ngeMe` respectively.

# Installation

Current community packages are hosted on https://packagecloud.io/StackStorm. For detailed instructions how install st2 and perform basic configuration follow these instructions:

- [Ubuntu/Debian](https://docs.stackstorm.com/install/deb.html)
- [RHEL8/RockyLinux8](https://docs.stackstorm.com/install/rhel8.html)

## Adding Support For a New Distribution

If you are adding support for a new distribution for which ``packagingbuild`` and ``packagingtest``
If you are adding support for a new distribution for which `packagingbuild` and `packagingtest`
images are not yet published to Docker Hub and you want to test the build pipeline locally, you
need to update ``docker-compose.yml`` file to use locally built Docker images.
need to update `docker-compose.yml` file to use locally built Docker images.

For example:

```yaml
...

focal:
...
image: quay.io/stackstorm/packagingrunner
...
...

focalbuild:
...
image: focalbuild
services:
...

...

focaltest:
jammy:
...
image: quay.io/stackstorm/packagingrunner
...
...
image: focaltest
jammybuild:
...
image: jammybuild
...
...
jammytest:
...
image: jammytest
...
```

NOTE: Main ``distro`` definition (e.g. ``focal``, etc.) needs to use packaging runner image.
NOTE: Main `distro` definition (e.g. `jammy`, etc.) needs to use packaging runner image.

As you can see, ``image`` attribute references local image tagged ``focalbuild`` instead of a
remote image (e.g. ``stackstorm/packagingbuild:focal`` or similar).
As you can see, `image` attribute references local image tagged `jammybuild` instead of a
remote image (e.g. `stackstorm/packagingbuild:jammy` or similar).

Before that will work, you of course also need to build those images locally.

For example:

```bash
cd ~/st2packaging-dockerfiles/packagingbuild/focal
docker build -t focalbuild .
cd ~/st2packaging-dockerfiles/packagingbuild/jammy
docker build -t jammybuild .

cd ~/st2packaging-dockerfiles/packagingtest/focal/systemd
docker build -t focaltest .
cd ~/st2packaging-dockerfiles/packagingtest/jammy/systemd
docker build -t jammytest .
```

# License and Authors

* Author:: StackStorm (st2-dev) (<[email protected]>)
* Author:: Denis Baryshev (<[email protected]>)
- Author:: StackStorm (st2-dev) (<[email protected]>)
- Author:: Denis Baryshev (<[email protected]>)
5 changes: 5 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
VAGRANTFILE_API_VERSION = "2"

VIRTUAL_MACHINES = {
:jammy => {
:hostname => 'st2-packages-jammy',
:box => 'ubuntu/jammy64',
:ip => '192.168.16.26',
},
:focal => {
:hostname => 'st2-packages-focal',
:box => 'ubuntu/focal64',
Expand Down
Loading

0 comments on commit fa8f3e5

Please sign in to comment.