Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CircleCI 'machine' executors with QEMU emulation to build packages for different architectures #3263

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8222ddf
Use CircleCI 'machine' executors with QEMU emulation to build packages
martin-g Mar 26, 2020
e47aa80
Try to build Alpine Linux .apk for aarch64 without installing depende…
martin-g Mar 26, 2020
009bff2
Pass '--credential yes' when registering QEMU
martin-g Mar 26, 2020
9c8404c
Merge branch 'feature/create-aarch64-packages3' into feature/create-a…
martin-g Mar 26, 2020
aef7956
t130
martin-g Mar 26, 2020
fae1ed5
Merge branch 'feature/create-aarch64-packages3' into feature/create-a…
martin-g Mar 27, 2020
c568c21
Add Debian buster & stretch and Centos:8
martin-g Mar 27, 2020
e264de9
Merge branch 'feature/create-aarch64-packages3' into feature/create-a…
martin-g Mar 27, 2020
65396b6
Install 'epel-release' before other packages.
martin-g Mar 27, 2020
3325d0e
Install different packages for different versions of CentOS
martin-g Mar 27, 2020
f0f1988
Re-enable distcheck jobs
martin-g Mar 27, 2020
42d890c
Merge branch 'master' into feature/create-aarch64-packages2
martin-g Apr 3, 2020
322af97
Move 'tar_pkg_tools' job after 'dist' job to reduce the diff size
martin-g Apr 3, 2020
838aed2
Fix 'run' description - it should use the correct extension (rpm|deb|…
martin-g Apr 3, 2020
f6220ce
Simplify by inlining two aliases which are used at only one place
martin-g Apr 3, 2020
f3f6a2a
Improve 'dist' job description
martin-g Apr 3, 2020
89cf1d3
list the contents of ~/workspace in every job
martin-g Apr 3, 2020
643e924
Remove '.weekly' suffix for Alpine versions
martin-g Apr 3, 2020
255736b
Add a README that explains how CircleCI is being used to create packa…
martin-g Apr 8, 2020
42b5854
Inline &pkg_parameters since it is used just once
martin-g Apr 8, 2020
de6a532
Use -z to check for undefined env variable
martin-g Apr 8, 2020
712f082
Use Python 3 instead of 2
martin-g Apr 8, 2020
ad5bb45
Remove useless user 'varnish' for Debian packaging
martin-g Apr 8, 2020
b6114cc
Inline 'activate_qemu' step since it is used just once
martin-g Apr 8, 2020
4ffeb7d
Use many instances of 'package' job, differentiated by name
martin-g Apr 8, 2020
e85ce18
Remove useless 'varnish' user
martin-g Apr 8, 2020
89bfb74
Call 'package' job with name 'aarch64-centos-8'
martin-g Apr 8, 2020
cc11d16
Register QEMU with `--persistent yes` to be able to run arm64v8 Docke…
martin-g Apr 8, 2020
5f92676
Remove ':register' for qemu-user-static activation
martin-g Apr 9, 2020
a6c452f
Try to register QEMU with -it and without sudo
martin-g Apr 9, 2020
52cc963
Print the linux version before trying to register QEMU
martin-g Apr 9, 2020
a6789b8
CircleCI runs on Ubuntu 14.04.4, with kernel 4.4.0, which does not su…
martin-g Apr 9, 2020
0d7cd42
Use newer Ubuntu image for machine executor
martin-g Apr 9, 2020
0b907c8
Docker layer caching is a paid feature
martin-g Apr 9, 2020
092659c
Fix image for Ubuntu Bionic aarch64
martin-g Apr 9, 2020
549205e
Remove debug statements
martin-g Apr 9, 2020
c7cc757
Use mine fork of pkg-varnish-cache where I moved some build dependenc…
martin-g Apr 9, 2020
871f51d
Fix YAML issue with comments
martin-g Apr 9, 2020
1296a6f
Reduce the installed dependencies to the ones required to create the …
martin-g Apr 9, 2020
8c68560
Reduce the number of the installed dependencies to the ones required …
martin-g Apr 9, 2020
b157f44
Fix the Docker image name for CentOS 7 on ARM64
martin-g Apr 9, 2020
578b554
Merge branch 'feature/create-aarch64-packages2' into feature/optimiza…
martin-g Apr 9, 2020
86f0079
Use mine branch instead of 'weekly'
martin-g Apr 9, 2020
f20ae9f
Disable all jobs but CentOS 7 ones
martin-g Apr 9, 2020
0525571
Disable non-CentOS distcheck jobs
martin-g Apr 9, 2020
923611c
Remove CentOS Vault yum repo because of https://bugs.centos.org/view.…
martin-g Apr 9, 2020
e421864
Also remove Sources repo because it has Vault entries too
martin-g Apr 9, 2020
8bf9431
Re-enable the disabled jobs
martin-g Apr 9, 2020
ff72514
Update the README after renaming the packaging jobs to 'package'
martin-g Apr 9, 2020
48c8786
Remove usage of store_artifacts for the intermediate steps.
martin-g Apr 10, 2020
e345f0c
Update CircleCI README to explain why '--persistent yes' is needed
martin-g Apr 10, 2020
d3da09e
Get rid of ~/workspace folder
martin-g Apr 10, 2020
24dc7b6
Package step does not need to checkout the code
martin-g Apr 10, 2020
02db695
Save .circleci/ folder in the workspace
martin-g Apr 10, 2020
236a401
Do not use 'build' folder for Debian packaging
martin-g Apr 10, 2020
8a8d48d
Untar only varnish-cache.tgz
martin-g Apr 10, 2020
84e68cb
Change the owner of /varnish-cache to user builder
martin-g Apr 10, 2020
455e490
Use the default working directory (~/project) because this is where t…
martin-g Apr 10, 2020
0139b4d
The name of the archive is just varnish-***, not varnish-cache-***
martin-g Apr 10, 2020
a6937c4
Use /workspace as a working directory and attach the workspace to it
martin-g Apr 10, 2020
52ffb20
Change the ownership of /workspace folder because of:
martin-g Apr 10, 2020
f887fc6
Reset the ownership of the packages folder
martin-g Apr 10, 2020
d5d6c35
Remove attach_workspace on the default folder
martin-g Apr 10, 2020
82c3f58
Allow to read Alpine's packages outside of Docker
martin-g Apr 11, 2020
dadb6d7
Attach the workspace at ~/project
martin-g Apr 11, 2020
dbbf6eb
Minor spelling correction
martin-g Apr 23, 2020
33d32dc
Merge branch 'feature/create-aarch64-packages2' into feature/optimiza…
martin-g Apr 23, 2020
a7dae2e
Use -slim versions of the Debian Docker images also for x64
martin-g Apr 23, 2020
75754f1
Revert changes needed to use my fork of pkg-varnish-cache
martin-g Apr 30, 2020
830502c
Merge branch 'feature/optimizations-from-pr-3263' into feature/create…
martin-g Apr 30, 2020
5f465d8
Merge branch 'master' into feature/create-aarch64-packages2
martin-g Apr 30, 2020
8214bbb
Merge branch 'master' into feature/create-aarch64-packages2
martin-g May 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .circleci/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Multiarch building, testing & packaging
=======================================

Varnish Cache uses CircleCI_ for building, testing and creating packages for several Linux distributions for both x86_64 and aarch64 architectures.

Since CircleCI provides only x86_64 VMs the setup uses Docker and QEMU to be able to build, test and create packages for aarch64.
This is accomplished by registering `qemu-user-static` for the CircleCI `machine` executor:

``sudo docker run --rm --privileged multiarch/qemu-user-static --reset --credential yes --persistent yes``

Note 1: **--credential yes** is needed so that *setuid* flag is working. Without it `sudo` does not work in the Docker containers with architecture
different than x86_64.
Note 2: **--persistent yes** is needed so that there is no need to use `:register` tag. This way one can run locally pure foreign arch Docker
images, like the official `arm64v8/***` ones. O

With QEMU registered each build step can start a Docker image for any of the supported architectures to execute the `configure`, `make`, package steps.

Pipeline steps
-----------

1. The first two steps that run in parallel are:

1.1. ``tar_pkg_tools`` - this step checks out pkg-varnish-cache_ with the packaging descriptions for Debian, RedHat and Alpine, and stores them in the build workspace for the next steps in the pipeline. Additionally the result files are stored as artefacts in case they are needed for debugging.

1.2. ``dist`` - this step creates the source code distribution of Varnish Cache as compressed archive (varnish-cache-x.y.z.tar.gz). This archive is also stored in the build workspace and used later by the packaging steps. Again the archive is stored as an artefact for debugging.


2. The next steps in the pipeline (again running in parallel) are:

2.1. ``distcheck`` - untars the source code distribution and builds (*configure*, *make*) it for the different CPU architectures

2.2. ``package`` - step that creates the packages (e.g. .rpm, .deb) for each supported CPU architecture, Linux distribution and its major
version (e.g. *x64_centos_7*, *aarch64_ubuntu_bionic*, *x64_alpine_3*, etc.). This step creates a Dockerfile on the fly by using a base Docker image. This custom Docker image executes a Shell script that has the recipe for creating the package for the specific Linux flavor, e.g. *make-rpm-packages.sh*. The step stores the packages in the build workspace and as an artefact.

3. Finally, if the previous steps are successful, a final step is executed - ``collect_packages``. This step creates an archive with all packages and stores it as an artefact that can be uploaded to PackageCloud_.


More
-------------

- This setup can be easily extended for any CPU architectures supported by QEMU and for any Linux distributions which have Docker image. To do this
one needs to add a new ``package`` job with the proper parameters for it.
- At the moment the setup uses *raw* Docker images and installs the required Linux distribution dependencies before running the tests/build/packaging code. This could be optimized to save some execution time by creating custom Docker images that extend the current ones and pre-installs the required dependencies.


.. _CircleCI: https://app.circleci.com/pipelines/github/varnishcache/varnish-cache
.. _pkg-varnish-cache: https://github.com/varnishcache/pkg-varnish-cache
.. _PackageCloud: https://packagecloud.io/varnishcache/
Loading