Skip to content

Commit 328e762

Browse files
authored
Docker images v2 (#1021)
New naming scheme appends `-v#` to the image name. The tag part is not changed (so you can still tell the difference between Ubuntu versions) Removed Docker Hub pushes. Now we use `ghcr.io` for both images. We no longer set `CC` and `CXX` in the image. We now use the default compiler (GCC_ for cross-compilation on because Ubuntu and vcpkg have better support for cross-compilation when using GCC.
1 parent 83e7576 commit 328e762

File tree

3 files changed

+60
-35
lines changed

3 files changed

+60
-35
lines changed
Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Docker Build Images (AMD64)
22

3+
env:
4+
# Also remember to change the 'docker/build.sh' script
5+
IMAGE_VER: "v2"
6+
37
on:
48
schedule:
59
# Once every Wednesday at 00:00
@@ -26,40 +30,59 @@ jobs:
2630
matrix:
2731
# arch is to tag docker images for uniqueness
2832
host:
29-
- { name: 'ubuntu-20.04', arch: '' }
33+
- { name: 'ubuntu-22.04', arch: '' }
3034
container:
31-
- { distro: 'ubuntu', version: '20.04', codename: 'focal' }
32-
- { distro: 'ubuntu', version: '22.04', codename: 'jammy' }
35+
- { version: '20.04', codename: 'focal' }
36+
- { version: '22.04', codename: 'jammy' }
3337

3438
runs-on: ${{ matrix.host.name }}
3539

40+
permissions:
41+
packages: write
42+
contents: read
43+
3644
steps:
3745
- name: Cleanup working directory with container root
3846
run: |
3947
docker run --rm -v $(pwd):/workspace -w /workspace ubuntu:latest find . -name . -o -prune -exec rm -rf -- {} + || true
4048
- uses: actions/checkout@v3
41-
- name: Build and Push
49+
- name: Generate Image Name
50+
env:
51+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
52+
run: |
53+
test_name=""
54+
if [[ "${GITHUB_REF}" != "refs/heads/master" ]] ; then
55+
test_name="test-${BRANCH_NAME////_}-"
56+
fi
57+
echo "IMAGE_NAME=ghcr.io/lifting-bits/cxx-common/${test_name}vcpkg-builder-ubuntu-${{ env.IMAGE_VER }}:${{ matrix.container.version }}${{ matrix.host.arch }}" >> ${GITHUB_ENV}
58+
59+
- name: Build caching image
4260
working-directory: docker
4361
run: |
4462
# Pull freshest ubuntu Docker image
4563
docker pull ubuntu:${{ matrix.container.version}}
4664
47-
docker build -f Dockerfile.ubuntu.vcpkg --target caching --no-cache --build-arg "DISTRO_VERSION=${{ matrix.container.codename }}" -t "docker.pkg.github.com/${DOCKER_TAG}" .
48-
# Docker image with NuGet support goes to github packages for CI use only
49-
if [[ "${GITHUB_REF}" == "refs/heads/master" ]] ; then
50-
docker login docker.pkg.github.com -u publisher -p "${GITHUB_PACKAGE_REGISTRY_TOKEN}"
51-
for i in 1 2 3; do docker push "docker.pkg.github.com/${DOCKER_TAG}" && break || sleep 10; done
52-
fi
65+
docker build -f Dockerfile.ubuntu.vcpkg \
66+
--no-cache \
67+
--target caching \
68+
--build-arg "DISTRO_VERSION=${{ matrix.container.codename }}" \
69+
-t "${IMAGE_NAME}" \
70+
.
5371
54-
# NOTE: Docker Hub only allows one slash in tag
55-
docker build -f Dockerfile.ubuntu.vcpkg --target base --build-arg "DISTRO_VERSION=${{ matrix.container.codename }}" -t "trailofbits/cxx-common-vcpkg-builder-${{ matrix.container.distro }}:${{ matrix.container.version }}${{ matrix.host.arch }}" .
56-
# Smaller Docker image without NuGet support goes to Docker Hub for users
57-
if [[ "${GITHUB_REF}" == "refs/heads/master" ]] ; then
58-
docker login -u "${DOCKER_HUB_USER}" -p "${DOCKER_HUB_TOKEN}"
59-
for i in 1 2 3; do docker push "trailofbits/cxx-common-vcpkg-builder-${{ matrix.container.distro }}:${{ matrix.container.version }}${{ matrix.host.arch }}" && break || sleep 10; done
60-
fi
61-
env:
62-
DOCKER_TAG: lifting-bits/cxx-common/vcpkg-builder-${{ matrix.container.distro }}:${{ matrix.container.version }}${{ matrix.host.arch }}
63-
GITHUB_PACKAGE_REGISTRY_TOKEN: ${{ secrets.GITHUB_PACKAGE_REGISTRY_TOKEN }}
64-
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
65-
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
72+
- name: Log in to registry
73+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
74+
75+
- name: Push caching image
76+
run: docker push "${IMAGE_NAME}"
77+
78+
- name: Build and Push non-caching image
79+
if: github.ref == 'refs/heads/master'
80+
run: |
81+
# Only push smaller image on default branch. This could change in the
82+
# future if we actually need to test the smaller image before merging
83+
docker build -f Dockerfile.ubuntu.vcpkg \
84+
--target base \
85+
--build-arg "DISTRO_VERSION=${{ matrix.container.codename }}" \
86+
-t "${IMAGE_NAME}" \
87+
.
88+
docker push "${IMAGE_NAME}"

docker/Dockerfile.ubuntu.vcpkg

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG DISTRO_VERSION=focal
2-
ARG LLVM_VERSION=14
2+
ARG LLVM_VERSION=16
33

44
ARG BUILD_BASE=ubuntu:${DISTRO_VERSION}
55
FROM ${BUILD_BASE} as base
@@ -17,16 +17,20 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
1717
apt-add-repository ppa:git-core/ppa --yes && \
1818
wget "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-$(uname -m).sh" && \
1919
/bin/bash cmake-*.sh --skip-license --prefix=/usr/local && rm cmake-*.sh && \
20-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
21-
echo "deb http://apt.llvm.org/${DISTRO_VERSION}/ llvm-toolchain-${DISTRO_VERSION}-${LLVM_VERSION} main" >> /etc/apt/sources.list && \
22-
echo "deb-src http://apt.llvm.org/${DISTRO_VERSION}/ llvm-toolchain-${DISTRO_VERSION}-${LLVM_VERSION} main" >> /etc/apt/sources.list && \
20+
\
21+
wget https://apt.llvm.org/llvm.sh && \
22+
chmod +x llvm.sh && \
23+
./llvm.sh ${LLVM_VERSION} clang lld && \
24+
\
2325
apt-get update && apt-get upgrade --yes && \
2426
apt-get install --yes --no-install-recommends \
25-
"$( [ "$(uname -m)" != "aarch64" ] && echo "g++-multilib")" \
26-
"$( [ "$(uname -m)" = "aarch64" ] && echo "libstdc++-*-dev:armhf")" \
2727
libtinfo-dev libzstd-dev python3-pip python3-setuptools python-setuptools \
28-
build-essential g++ gcc clang lld clang-${LLVM_VERSION} lld-${LLVM_VERSION} ninja-build \
28+
build-essential binutils-multiarch g++ gcc clang lld clang-${LLVM_VERSION} lld-${LLVM_VERSION} ninja-build \
2929
pixz xz-utils make rpm curl unzip tar git zip python3 pkg-config && \
30+
apt-get install --yes --no-install-recommends \
31+
$( [ "$(uname -m)" = "x86_64" ] && echo crossbuild-essential-i386 crossbuild-essential-arm64 linux-libc-dev-amd64-cross) \
32+
"$( [ "$(uname -m)" = "aarch64" ] && echo "libstdc++-$(gcc -dumpversion | cut -f1 -d.)-dev:armhf")" && \
33+
\
3034
apt-get clean --yes && \
3135
rm -rf /var/lib/apt/lists/* && \
3236
\
@@ -37,11 +41,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
3741
cmake --build build --target install && \
3842
cd .. && rm -rf ccache-ccache-*
3943

40-
# Default to system clang because things will break if mixing objects compiled with system clang and clang-14
41-
ENV CC=/usr/bin/clang \
42-
CXX=/usr/bin/clang++
43-
44-
4544
# Much heavier installation due to mono dependency for NuGet
4645
FROM base as caching
4746
ARG DISTRO_VERSION

docker/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ 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+
811
# Ubuntu versions to build
912
UBUNTU_VERSION_MATRIX=( "focal" "jammy" )
1013

@@ -13,7 +16,7 @@ for version in "${UBUNTU_VERSION_MATRIX[@]}"; do
1316
docker pull "ubuntu:${version}"
1417

1518
# Image identification
16-
tag="vcpkg-builder-ubuntu:${version}"
19+
tag="vcpkg-builder-ubuntu-${IMAGE_VER}:${version}"
1720

1821
# Build
1922
docker build \

0 commit comments

Comments
 (0)