Skip to content

Commit c203bb4

Browse files
authored
Docker images for building native toolset (#17)
* Updated build docker images to GCC 15, introduced inside image conan-cache * Added cmake receipt to satisfy other packages build dependencies on ARM * Switched build to ARM64 runner
1 parent db31e8f commit c203bb4

File tree

57 files changed

+2797
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2797
-474
lines changed

.github/workflows/build-arch-matrix-generator.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
echo "${SELECTED_ARCH} selected. Adding arm64"
3939
MATRIX+='{"arch": "linux-arm64", "goarch": "arm64", "packages": "deb rpm"},{"arch": "linuxmusl-arm64", "goarch": "arm64", "packages": "apk"},'
4040
fi
41-
echo "matrix-combinations={\"include\":[$MATRIX]}"
4241
42+
# Remove trailing comma
43+
MATRIX="${MATRIX%,}"
44+
45+
echo "matrix-combinations={\"include\":[$MATRIX]}"
4346
echo "matrix-combinations={\"include\":[$MATRIX]}" >> $GITHUB_OUTPUT

.github/workflows/build-native.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
build-native:
3434
name: build-agent-library
35-
runs-on: 'ubuntu-latest'
35+
runs-on: ${{ matrix.goarch == 'arm64' && 'oracle-4cpu-16gb-arm64' || 'ubuntu-latest' }}
3636
needs: setup-build-matrix
3737
timeout-minutes: 300
3838
strategy:
@@ -42,10 +42,19 @@ jobs:
4242
BUILD_ARCHITECTURE: ${{ matrix.arch }}
4343
steps:
4444
- uses: actions/checkout@v6
45-
- if: ${{ matrix.goarch == 'arm64' }}
46-
uses: docker/setup-qemu-action@v3
45+
# - if: ${{ matrix.goarch == 'arm64' }}
46+
# uses: docker/setup-qemu-action@v3
47+
# with:
48+
# platforms: arm64
49+
- name: Set up Docker Buildx
50+
if: contains(matrix.arch, 'arm64')
51+
id: buildx
52+
uses: docker/setup-buildx-action@v3
4753
with:
48-
platforms: arm64
54+
driver-opts: |
55+
image=moby/buildkit:latest
56+
network=host
57+
4958
- name: Build
5059
run: |
5160
uname -a

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ concurrency:
2323
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
2424

2525
jobs:
26+
build-compiler:
27+
uses: ./.github/workflows/native-dev-tools-build.yml
28+
secrets: inherit
29+
with:
30+
build_arch: all
2631
build-native:
32+
needs:
33+
- build-compiler
2734
uses: ./.github/workflows/build-native.yml
2835
with:
2936
build_arch: all
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
name: native-dev-tools-build
3+
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
build_arch:
9+
required: false
10+
type: string
11+
default: 'x86_64'
12+
workflow_dispatch:
13+
inputs:
14+
build_arch:
15+
type: choice
16+
description: Build architecture
17+
default: 'x86_64'
18+
options:
19+
- all
20+
- x86_64
21+
- arm64
22+
push:
23+
paths:
24+
- 'prod/native/building/dockerized/**'
25+
branches:
26+
- main
27+
28+
jobs:
29+
setup-build-matrix:
30+
uses: ./.github/workflows/build-arch-matrix-generator.yml
31+
with:
32+
build_arch: ${{ inputs.build_arch }}
33+
34+
build-compiler-image:
35+
runs-on: ${{ matrix.goarch == 'arm64' && 'oracle-4cpu-16gb-arm64' || 'ubuntu-latest' }}
36+
needs: setup-build-matrix
37+
env:
38+
DOCKER_BUILDKIT: 1
39+
strategy:
40+
fail-fast: false
41+
matrix: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations) }}
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v6
45+
46+
- name: Set up Docker Buildx
47+
if: contains(matrix.arch, 'arm64')
48+
id: buildx
49+
uses: docker/setup-buildx-action@v3
50+
with:
51+
driver-opts: |
52+
image=moby/buildkit:latest
53+
network=host
54+
55+
- name: Set up Docker Compose
56+
uses: docker/setup-compose-action@v1
57+
58+
- name: Log into Docker.io
59+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
60+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
61+
with:
62+
username: ${{ vars.DOCKER_USERNAME }}
63+
password: ${{ secrets.DOCKER_TOKEN_PHP_DISTRO }}
64+
65+
- name: Extract image names from docker-compose.yml
66+
id: images
67+
working-directory: prod/native/building/dockerized
68+
run: |
69+
echo "::group::Extracting image names for architecture: ${{ matrix.arch }}"
70+
71+
COMPILER_IMAGE=$(docker compose config --images | grep ${{ matrix.arch }} | grep -v conancache)
72+
CONANCACHE_IMAGE=$(docker compose config --images | grep conancache | grep ${{ matrix.arch }})
73+
74+
echo "gcc_image=${COMPILER_IMAGE}" >> $GITHUB_OUTPUT
75+
echo "conan_cache_image=${CONANCACHE_IMAGE}" >> $GITHUB_OUTPUT
76+
77+
echo "Compiler image: ${COMPILER_IMAGE}"
78+
echo "Conan cache image: ${CONANCACHE_IMAGE}"
79+
80+
- name: Check if GCC base image exists
81+
id: check-gcc
82+
run: |
83+
IMAGE_NAME="${{ steps.images.outputs.gcc_image }}"
84+
echo "Checking for image: ${IMAGE_NAME}"
85+
86+
if docker manifest inspect ${IMAGE_NAME} > /dev/null 2>&1; then
87+
echo "exists=true" >> $GITHUB_OUTPUT
88+
echo "✓ Image already exists on Docker Hub"
89+
else
90+
echo "exists=false" >> $GITHUB_OUTPUT
91+
echo "✗ Image does not exist, will build"
92+
fi
93+
94+
- name: Build GCC base image
95+
if: steps.check-gcc.outputs.exists == 'false'
96+
working-directory: prod/native/building/dockerized
97+
env:
98+
BUILDX_BAKE_ENTITLEMENTS_FS: 0
99+
run: |
100+
echo "Building GCC base image for ${{ matrix.arch }}"
101+
102+
# For fork PRs on ARM64, use --load to make image available locally
103+
# For same-repo or push to main, build normally (will be pushed later)
104+
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]] && [[ "${{ matrix.arch }}" == *"arm64"* ]]; then
105+
echo "Fork PR on ARM64: building with --load to make image available locally"
106+
docker buildx bake --load build_${{ matrix.arch }}
107+
else
108+
docker compose build build_${{ matrix.arch }}
109+
fi
110+
111+
- name: Push GCC base image to Docker Hub
112+
if: steps.check-gcc.outputs.exists == 'false' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
113+
working-directory: prod/native/building/dockerized
114+
run: |
115+
echo "Pushing GCC base image for ${{ matrix.arch }}"
116+
docker compose push build_${{ matrix.arch }}
117+
118+
- name: Check if Conan cache image exists
119+
id: check-conan
120+
run: |
121+
IMAGE_NAME="${{ steps.images.outputs.conan_cache_image }}"
122+
echo "Checking for image: ${IMAGE_NAME}"
123+
124+
if docker manifest inspect ${IMAGE_NAME} > /dev/null 2>&1; then
125+
echo "exists=true" >> $GITHUB_OUTPUT
126+
echo "✓ Conan cache image already exists on Docker Hub"
127+
else
128+
echo "exists=false" >> $GITHUB_OUTPUT
129+
echo "✗ Conan cache image does not exist, will build"
130+
fi
131+
- name: Build Conan cache image
132+
if: steps.check-conan.outputs.exists == 'false'
133+
working-directory: prod/native/building/dockerized
134+
env:
135+
BUILDX_BAKE_ENTITLEMENTS_FS: 0
136+
run: |
137+
echo "Building Conan cache image for ${{ matrix.arch }}"
138+
139+
# For fork PRs on ARM64, use --load to ensure image is available locally
140+
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]] && [[ "${{ matrix.arch }}" == *"arm64"* ]]; then
141+
echo "Fork PR on ARM64: building with --load"
142+
docker buildx bake --load build_${{ matrix.arch }}_conan
143+
else
144+
docker compose build build_${{ matrix.arch }}_conan
145+
fi
146+
147+
- name: Push Conan cache image
148+
if: steps.check-conan.outputs.exists == 'false' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
149+
working-directory: prod/native/building/dockerized
150+
run: |
151+
echo "Pushing Conan cache image for ${{ matrix.arch }}"
152+
docker compose push build_${{ matrix.arch }}_conan

prod/native/CMakeLists.txt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ otel_read_properties("../../project.properties" "_PROJECT_PROPERTIES_")
2020

2121
set(_PROJECT_PROPERTIES_VERSION_SHORT ${_PROJECT_PROPERTIES_VERSION})
2222

23-
if(DEFINED ENV{GITHUB_SHA})
24-
set(GITHUB_SHA $ENV{GITHUB_SHA})
25-
message(STATUS "GITHUB_SHA: ${GITHUB_SHA}")
26-
else()
27-
message(STATUS "GITHUB_SHA is not defined in the environment. Trying to get hash from source tree")
28-
include(otel_get_git_version)
29-
otel_git_get_hash(_COMMIT_HASH_REV)
30-
set(_PROJECT_PROPERTIES_VERSION "${_PROJECT_PROPERTIES_VERSION}~${_COMMIT_HASH_REV}")
23+
if(NOT DEFINED ENV{BUILDING_CONAN_DEPENDENCIES_ONLY})
24+
if(DEFINED ENV{GITHUB_SHA})
25+
set(GITHUB_SHA $ENV{GITHUB_SHA})
26+
message(STATUS "GITHUB_SHA: ${GITHUB_SHA}")
27+
else()
28+
message(STATUS "GITHUB_SHA is not defined in the environment. Trying to get hash from source tree")
29+
include(otel_get_git_version)
30+
otel_git_get_hash(_COMMIT_HASH_REV)
31+
set(_PROJECT_PROPERTIES_VERSION "${_PROJECT_PROPERTIES_VERSION}~${_COMMIT_HASH_REV}")
32+
endif()
3133
endif()
3234

3335
message(STATUS "Project version: ${_PROJECT_PROPERTIES_VERSION}")
@@ -113,6 +115,11 @@ foreach(_php_version ${_supported_php_versions})
113115
find_package(php-headers-${_php_version} ${_PROJECT_PROPERTIES_PHP_HEADERS_VERSION} REQUIRED)
114116
endforeach()
115117

118+
if(DEFINED ENV{BUILDING_CONAN_DEPENDENCIES_ONLY})
119+
message(STATUS "Building only conan dependencies, exiting")
120+
return()
121+
endif()
122+
116123
enable_testing()
117124

118125
add_subdirectory(libcommon)

prod/native/CMakePresets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
"name": "binutils",
2525
"hidden": true,
2626
"environment": {
27-
"PATH": "/opt/binutils-2.43/bin:$penv{PATH}"
27+
"PATH": "/opt/php-distro-build-binutils/bin:$penv{PATH}"
2828
}
2929
},
3030
{
3131
"name": "gcc",
3232
"hidden": true,
3333
"environment": {
34-
"COMPILER_HOME_PATH": "/opt/gcc-14.2.0"
34+
"COMPILER_HOME_PATH": "/opt/php-distro-build-gcc"
3535
},
3636
"cacheVariables": {
3737
"CMAKE_C_COMPILER": {

prod/native/building/conan/profiles/linux-arm64-release

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
os=Linux
33
arch=armv8
44
compiler=gcc
5-
compiler.version=14
5+
compiler.version=15
66
compiler.cppstd=20
77
compiler.libcxx=libstdc++11
88
compiler.libc=glibc
99
build_type=Release
1010

1111
[conf]
1212
tools.cmake.cmaketoolchain:generator=Unix Makefiles
13-
tools.build:compiler_executables={"c":"/opt/gcc-14.2.0/bin/gcc","cpp":"/opt/gcc-14.2.0/bin/g++"}
13+
tools.build:compiler_executables={"c":"/opt/php-distro-build-gcc/bin/gcc","cpp":"/opt/php-distro-build-gcc/bin/g++"}
1414

1515
[buildenv]
16-
CC=/opt/gcc-14.2.0/bin/gcc
17-
CXX=/opt/gcc-14.2.0/bin/g++
16+
CC=/opt/php-distro-build-gcc/bin/gcc
17+
CXX=/opt/php-distro-build-gcc/bin/g++
1818
LDFLAGS+=-static-libgcc
1919
LDFLAGS+=-static-libstdc++
2020
LDFLAGS+=-Wl,-Bstatic -latomic -Wl,-Bdynamic
21-
CC_FOR_BUILD=/opt/gcc-14.2.0/bin/gcc
21+
CC_FOR_BUILD=/opt/php-distro-build-gcc/bin/gcc

prod/native/building/conan/profiles/linux-x86-64-release

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
os=Linux
33
arch=x86_64
44
compiler=gcc
5-
compiler.version=14
5+
compiler.version=15
66
compiler.cppstd=20
77
compiler.libcxx=libstdc++11
88
compiler.libc=glibc
99
build_type=Release
1010

1111
[conf]
1212
tools.cmake.cmaketoolchain:generator=Unix Makefiles
13-
tools.build:compiler_executables={"c":"/opt/gcc-14.2.0/bin/gcc","cpp":"/opt/gcc-14.2.0/bin/g++"}
13+
tools.build:compiler_executables={"c":"/opt/php-distro-build-gcc/bin/gcc","cpp":"/opt/php-distro-build-gcc/bin/g++"}
1414

1515
[buildenv]
16-
CC=/opt/gcc-14.2.0/bin/gcc
17-
CXX=/opt/gcc-14.2.0/bin/g++
16+
CC=/opt/php-distro-build-gcc/bin/gcc
17+
CXX=/opt/php-distro-build-gcc/bin/g++
1818
LDFLAGS+=-static-libgcc
1919
LDFLAGS+=-static-libstdc++
20-
CC_FOR_BUILD=/opt/gcc-14.2.0/bin/gcc
20+
CC_FOR_BUILD=/opt/php-distro-build-gcc/bin/gcc

prod/native/building/conan/profiles/linuxmusl-arm64-release

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
os=Linux
33
arch=armv8
44
compiler=gcc
5-
compiler.version=14
5+
compiler.version=15
66
compiler.cppstd=20
77
compiler.libcxx=libstdc++11
88
compiler.libc=musl
99
build_type=Release
1010

1111
[conf]
1212
tools.cmake.cmaketoolchain:generator=Unix Makefiles
13-
tools.build:compiler_executables={"c":"/opt/gcc-14.2.0/bin/gcc","cpp":"/opt/gcc-14.2.0/bin/g++"}
13+
tools.build:compiler_executables={"c":"/opt/php-distro-build-gcc/bin/gcc","cpp":"/opt/php-distro-build-gcc/bin/g++"}
1414

1515
[buildenv]
16-
CC=/opt/gcc-14.2.0/bin/gcc
17-
CXX=/opt/gcc-14.2.0/bin/g++
16+
CC=/opt/php-distro-build-gcc/bin/gcc
17+
CXX=/opt/php-distro-build-gcc/bin/g++
1818
LDFLAGS+=-static-libgcc
1919
LDFLAGS+=-static-libstdc++
2020
LDFLAGS+=-Wl,-Bstatic -latomic -Wl,-Bdynamic
21-
CC_FOR_BUILD=/opt/gcc-14.2.0/bin/gcc
21+
CC_FOR_BUILD=/opt/php-distro-build-gcc/bin/gcc

prod/native/building/conan/profiles/linuxmusl-x86-64-release

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
os=Linux
33
arch=x86_64
44
compiler=gcc
5-
compiler.version=14
5+
compiler.version=15
66
compiler.cppstd=20
77
compiler.libcxx=libstdc++11
88
compiler.libc=musl
99
build_type=Release
1010

1111
[conf]
1212
tools.cmake.cmaketoolchain:generator=Unix Makefiles
13-
tools.build:compiler_executables={"c":"/opt/gcc-14.2.0/bin/gcc","cpp":"/opt/gcc-14.2.0/bin/g++"}
13+
tools.cmake:cmake_program=/opt/php-distro-build-cmake/bin/cmake
14+
tools.build:compiler_executables={"c":"/opt/php-distro-build-gcc/bin/gcc","cpp":"/opt/php-distro-build-gcc/bin/g++"}
1415

1516
[buildenv]
16-
CC=/opt/gcc-14.2.0/bin/gcc
17-
CXX=/opt/gcc-14.2.0/bin/g++
17+
CC=/opt/php-distro-build-gcc/bin/gcc
18+
CXX=/opt/php-distro-build-gcc/bin/g++
1819
LDFLAGS+=-static-libgcc
1920
LDFLAGS+=-static-libstdc++
20-
CC_FOR_BUILD=/opt/gcc-14.2.0/bin/gcc
21+
CC_FOR_BUILD=/opt/php-distro-build-gcc/bin/gcc

0 commit comments

Comments
 (0)