Skip to content

Commit e52ae7a

Browse files
authored
Publish arm docker base image (#1045)
Also builds images for the upcoming Ubuntu 24.04 LTS
1 parent db89911 commit e52ae7a

File tree

4 files changed

+189
-103
lines changed

4 files changed

+189
-103
lines changed

.github/workflows/vcpkg_docker.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Docker Build Images
2+
3+
# Based on https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
4+
5+
on:
6+
schedule:
7+
# Once every Wednesday at 00:00
8+
- cron: '0 0 * * 3'
9+
push:
10+
branches:
11+
- master
12+
paths:
13+
- 'docker/**'
14+
- '.github/workflows/vcpkg_docker.yml'
15+
pull_request:
16+
paths:
17+
- 'docker/**'
18+
- '.github/workflows/vcpkg_docker.yml'
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
env:
28+
# This needs to be the same as in the `merge` job
29+
# Also remember to change the 'docker/build.sh' script
30+
REGISTRY_IMAGE: ghcr.io/lifting-bits/cxx-common/vcpkg-builder-ubuntu-v2
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
platform:
35+
- linux/amd64
36+
- linux/arm64
37+
ubuntu_version:
38+
- 22.04
39+
- 24.04
40+
steps:
41+
- name: Prepare
42+
run: |
43+
platform="${{ matrix.platform }}"
44+
echo "PLATFORM_PAIR=${platform//\//-}" >> "${GITHUB_ENV}"
45+
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: Set up QEMU
50+
uses: docker/setup-qemu-action@v3
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Login to GHCR
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ghcr.io
59+
username: ${{ github.repository_owner }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
# BEGIN Copied to the next job
63+
- name: Generate Tag
64+
env:
65+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
66+
run: |
67+
test_tag=""
68+
if [[ "${GITHUB_REF}" != "refs/heads/${{ github.event.repository.default_branch }}" ]] ; then
69+
test_tag="test-${BRANCH_NAME////_}-"
70+
fi
71+
echo "TEST_TAG=${test_tag}" >> "${GITHUB_ENV}"
72+
73+
- name: Docker meta
74+
id: meta
75+
uses: docker/metadata-action@v5
76+
with:
77+
images: ${{ env.REGISTERY_IMAGE }}
78+
flavor: |
79+
latest=false
80+
tags: |
81+
type=raw,value=${{ env.TEST_TAG }}${{ matrix.ubuntu_version }}
82+
# END Copied to the next job
83+
84+
- name: Build and push by digest
85+
id: build
86+
uses: docker/build-push-action@v5
87+
with:
88+
context: docker
89+
file: docker/Dockerfile.ubuntu.vcpkg
90+
platforms: ${{ matrix.platform }}
91+
labels: ${{ steps.meta.outputs.labels }}
92+
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
93+
94+
- name: Export digest
95+
run: |
96+
mkdir -p /tmp/digests
97+
digest="${{ steps.build.outputs.digest }}"
98+
touch "/tmp/digests/${digest#sha256:}"
99+
100+
- name: Upload digest
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: digests-${{ matrix.ubuntu_version }}-${{ env.PLATFORM_PAIR }}
104+
path: /tmp/digests/*
105+
if-no-files-found: error
106+
retention-days: 1
107+
108+
merge:
109+
runs-on: ubuntu-latest
110+
needs:
111+
- build
112+
env:
113+
# This needs to be the same as in the `build` job
114+
REGISTRY_IMAGE: ghcr.io/lifting-bits/cxx-common/vcpkg-builder-ubuntu-v2
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
ubuntu_version:
119+
- 22.04
120+
- 24.04
121+
steps:
122+
- name: Download digests
123+
uses: actions/download-artifact@v4
124+
with:
125+
path: /tmp/digests
126+
pattern: digests-${{ matrix.ubuntu_version }}-*
127+
merge-multiple: true
128+
129+
- name: Set up Docker Buildx
130+
uses: docker/setup-buildx-action@v3
131+
132+
- name: Login to GHCR
133+
uses: docker/login-action@v3
134+
with:
135+
registry: ghcr.io
136+
username: ${{ github.repository_owner }}
137+
password: ${{ secrets.GITHUB_TOKEN }}
138+
139+
# BEGIN Copied to the previous job
140+
- name: Generate Tag
141+
env:
142+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
143+
run: |
144+
test_tag=""
145+
if [[ "${GITHUB_REF}" != "refs/heads/${{ github.event.repository.default_branch }}" ]] ; then
146+
test_tag="test-${BRANCH_NAME////_}-"
147+
fi
148+
echo "TEST_TAG=${test_tag}" >> "${GITHUB_ENV}"
149+
150+
- name: Docker meta
151+
id: meta
152+
uses: docker/metadata-action@v5
153+
with:
154+
images: ${{ env.REGISTRY_IMAGE }}
155+
flavor: |
156+
latest=false
157+
tags: |
158+
type=raw,value=${{ env.TEST_TAG }}${{ matrix.ubuntu_version }}
159+
# END Copied from the previous job
160+
161+
- name: Create manifest list and push
162+
working-directory: /tmp/digests
163+
run: |
164+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
165+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
166+
167+
- name: Inspect image
168+
run: |
169+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

.github/workflows/vcpkg_docker_amd64.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

docker/Dockerfile.ubuntu.vcpkg

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
ARG DISTRO_VERSION=focal
1+
ARG UBUNTU_VERSION=22.04
22
ARG LLVM_VERSION=16
33

4-
ARG BUILD_BASE=ubuntu:${DISTRO_VERSION}
5-
FROM ${BUILD_BASE} as base
6-
ARG DISTRO_VERSION
4+
FROM ubuntu:${UBUNTU_VERSION} as base
5+
ARG UBUNTU_VERSION
76
ARG LLVM_VERSION
87

98
# All build dependencies for vcpkg packages
@@ -15,16 +14,18 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
1514
apt-get update && apt-get install --yes apt-utils && apt-get upgrade --yes && \
1615
apt-get install --yes --no-install-recommends apt-transport-https software-properties-common gnupg ca-certificates wget && \
1716
apt-add-repository ppa:git-core/ppa --yes && \
18-
wget "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-$(uname -m).sh" && \
17+
wget "https://github.com/Kitware/CMake/releases/download/v3.28.1/cmake-3.28.1-linux-$(uname -m).sh" && \
1918
/bin/bash cmake-*.sh --skip-license --prefix=/usr/local && rm cmake-*.sh && \
2019
\
21-
wget https://apt.llvm.org/llvm.sh && \
22-
chmod +x llvm.sh && \
23-
./llvm.sh ${LLVM_VERSION} clang lld && \
20+
if [ "${UBUNTU_VERSION}" != "24.04" ] ; then \
21+
wget https://apt.llvm.org/llvm.sh && \
22+
chmod +x llvm.sh && \
23+
./llvm.sh ${LLVM_VERSION} clang lld ; \
24+
fi && \
2425
\
2526
apt-get update && apt-get upgrade --yes && \
2627
apt-get install --yes --no-install-recommends \
27-
libtinfo-dev libzstd-dev python3-pip python3-setuptools python-setuptools \
28+
libtinfo-dev libzstd-dev python3-pip python3-setuptools \
2829
build-essential binutils-multiarch g++ gcc clang lld clang-${LLVM_VERSION} lld-${LLVM_VERSION} ninja-build \
2930
pixz xz-utils make rpm curl unzip tar git zip python3 pkg-config && \
3031
apt-get install --yes --no-install-recommends \
@@ -37,21 +38,13 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
3738
cd ~ && mkdir build && cd build && \
3839
curl -s https://api.github.com/repos/ccache/ccache/releases/latest | grep tarball_url | cut -d '"' -f 4 | wget -i- -O - | tar -xz && \
3940
cd ccache-ccache-* && \
40-
cmake -S . -B build -G Ninja -DREDIS_STORAGE_BACKEND=OFF -DCMAKE_BUILD_TYPE=Release && \
41+
cmake -S . -B build -G Ninja -DREDIS_STORAGE_BACKEND=OFF -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release && \
4142
cmake --build build --target install && \
4243
cd .. && rm -rf ccache-ccache-*
4344

4445
# Much heavier installation due to mono dependency for NuGet
4546
FROM base as caching
46-
ARG DISTRO_VERSION
4747
RUN export DEBIAN_FRONTEND=noninteractive && \
48-
apt-get update && \
49-
\
50-
if [ ${DISTRO_VERSION} != "jammy" ] ; then \
51-
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
52-
echo "deb https://download.mono-project.com/repo/ubuntu stable-${DISTRO_VERSION} main" | tee /etc/apt/sources.list.d/mono-official-stable.list ; \
53-
fi && \
54-
\
5548
apt-get update && \
5649
apt-get install --yes mono-devel && \
5750
apt-get clean --yes && \

docker/build.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@ set -euo pipefail
55
# Builds base images with all required dependencies to bootstrap vcpkg and
66
# build vcpkg libraries as well as all lifting-bits tools
77

8-
# Also remember to change the '.github/workflows/vcpkg_docker_amd64.yml' variable
9-
IMAGE_VER=v2
10-
118
# Ubuntu versions to build
12-
UBUNTU_VERSION_MATRIX=( "focal" "jammy" )
9+
UBUNTU_VERSION_MATRIX=( "22.04" "24.04" )
1310

14-
for version in "${UBUNTU_VERSION_MATRIX[@]}"; do
11+
for ubuntu_version in "${UBUNTU_VERSION_MATRIX[@]}"; do
1512
# Always pull from upstream
16-
docker pull "ubuntu:${version}"
13+
docker pull "ubuntu:${ubuntu_version}"
1714

18-
# Image identification
19-
tag="vcpkg-builder-ubuntu-${IMAGE_VER}:${version}"
15+
# Image identification. "v2" Image version is to identify big changes to the
16+
# build toolchain like LLVM version
17+
# Also remember to change the '.github/workflows/vcpkg_docker.yml' variable
18+
image="vcpkg-builder-ubuntu-v2"
2019

2120
# Build
2221
docker build \
2322
-f Dockerfile.ubuntu.vcpkg \
2423
--no-cache \
25-
--build-arg "DISTRO_VERSION=${version}" \
26-
-t "${tag}" \
24+
--build-arg "UBUNTU_VERSION=${ubuntu_version}" \
25+
-t "${image}:${ubuntu_version}" \
2726
.
2827
done

0 commit comments

Comments
 (0)