Skip to content

Commit f61a843

Browse files
authored
chore(build): add arm docker builds (#36)
1 parent d7358bd commit f61a843

File tree

8 files changed

+128
-42
lines changed

8 files changed

+128
-42
lines changed

.github/workflows/build_linux_profiler.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,29 @@ on:
77
branches: [main]
88

99
jobs:
10-
build-linux-profiler:
10+
build-linux-profiler-x86_64:
1111
runs-on: ubuntu-latest
1212
env:
1313
DOCKER_BUILDKIT: 1
1414
strategy:
1515
matrix:
16-
include:
17-
- name: glibc
18-
dockerfile: Pyroscope.Dockerfile
19-
- name: musl
20-
dockerfile: Pyroscope.musl.Dockerfile
16+
name: ['glibc', 'musl']
2117
steps:
2218
- name: Checkout
2319
uses: actions/checkout@v2
2420
with:
2521
submodules: 'true'
26-
- name: Build in Docker
27-
run: >
28-
docker build -f ${{ matrix.dockerfile }}
29-
-t pyroscope/pyroscope-dotnet:latest-${{ matrix.name }}
30-
.
22+
- run: RELEASE_VERSION=dev-$(git rev-parse --short HEAD) ARCH=x86_64 LIBC=${{ matrix.name }} make docker/build
23+
build-linux-profiler-aarch64:
24+
runs-on: [self-hosted, Linux, ARM64]
25+
env:
26+
DOCKER_BUILDKIT: 1
27+
strategy:
28+
matrix:
29+
name: ['glibc', 'musl']
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
submodules: 'true'
35+
- run: RELEASE_VERSION=dev-$(git rev-parse --short HEAD) ARCH=aarch64 LIBC=${{ matrix.name }} make docker/build

.github/workflows/tag_linux.yml

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,75 @@ on:
66
- v*-pyroscope
77

88
jobs:
9-
release-linux-profiler:
9+
release-linux-profiler-x86_64:
1010
runs-on: ubuntu-latest
1111
env:
1212
DOCKER_BUILDKIT: 1
13+
ARCH: x86_64
14+
LIBC: ${{ matrix.name }}
15+
strategy:
16+
matrix:
17+
name: ['glibc', 'musl']
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
submodules: 'true'
23+
- uses: docker/login-action@v2
24+
name: Login to Docker Hub
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
28+
- run: make docker/build
29+
- run: make docker/push
30+
- run: make docker/archive
31+
- name: Release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
files: ./*.tar.gz
35+
release-linux-profiler-aarch64:
36+
runs-on: [self-hosted, Linux, ARM64]
37+
env:
38+
DOCKER_BUILDKIT: 1
39+
ARCH: aarch64
40+
LIBC: ${{ matrix.name }}
1341
strategy:
1442
matrix:
15-
include:
16-
- name: glibc
17-
dockerfile: Pyroscope.Dockerfile
18-
- name: musl
19-
dockerfile: Pyroscope.musl.Dockerfile
43+
name: ['glibc', 'musl']
2044
steps:
2145
- name: Checkout
2246
uses: actions/checkout@v2
2347
with:
2448
submodules: 'true'
25-
- name: Set env
26-
run: |
27-
echo "RELEASE_VERSION=$(echo $GITHUB_REF | grep -oP '(?<=refs/tags/v).*(?=-pyroscope)')" >> $GITHUB_ENV
2849
- uses: docker/login-action@v2
2950
name: Login to Docker Hub
3051
with:
3152
username: ${{ secrets.DOCKERHUB_USERNAME }}
3253
password: ${{ secrets.DOCKERHUB_PASSWORD }}
33-
- name: Build in Docker & push
34-
run: >
35-
docker buildx build
36-
-t pyroscope/pyroscope-dotnet:${RELEASE_VERSION}-${{ matrix.name }}
37-
-t pyroscope/pyroscope-dotnet:latest-${{ matrix.name }}
38-
--push
39-
-f ${{ matrix.dockerfile }}
40-
.
41-
- name: Create tar archive
42-
run: docker build -f ${{ matrix.dockerfile }} -o out.${{ matrix.name }} . && tar -czvf pyroscope.${{ matrix.name }}.tar.gz -C out.${{ matrix.name }} .
54+
- run: make docker/build
55+
- run: make docker/push
56+
- run: make docker/archive
4357
- name: Release
4458
uses: softprops/action-gh-release@v1
4559
with:
46-
files: ./pyroscope.${{ matrix.name }}.tar.gz
60+
files: ./*.tar.gz
61+
release-linux-profiler:
62+
needs: ['release-linux-profiler-x86_64', 'release-linux-profiler-aarch64']
63+
runs-on: ubuntu-latest
64+
env:
65+
DOCKER_BUILDKIT: 1
66+
LIBC: ${{ matrix.name }}
67+
strategy:
68+
matrix:
69+
name: ['glibc', 'musl']
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v2
73+
with:
74+
submodules: 'true'
75+
- uses: docker/login-action@v2
76+
name: Login to Docker Hub
77+
with:
78+
username: ${{ secrets.DOCKERHUB_USERNAME }}
79+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
80+
- run: make docker/manifest

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ obj/*
365365
.ionide/
366366
/devenv.bat
367367
CMakeCache.txt
368-
Makefile
369368
_deps/
370369
CMakeFiles/
371370
lib/

Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
LIBC ?= glibc
2+
ARCH ?= x86_64
3+
RELEASE_VERSION ?= $(shell git describe --tags --always --dirty | grep -oP '(?<=v).*(?=-pyroscope)')
4+
DOCKER_IMAGE ?= pyroscope/pyroscope-dotnet
5+
6+
ifeq ($(LIBC),musl)
7+
DOCKERFILE := Pyroscope.musl.Dockerfile
8+
else ifeq ($(LIBC),glibc)
9+
DOCKERFILE := Pyroscope.Dockerfile
10+
else
11+
$(error LIBC must be either musl or glibc)
12+
endif
13+
14+
ifeq ($(ARCH),x86_64)
15+
else ifeq ($(ARCH),aarch64)
16+
else
17+
$(error ARCH must be either x86_64, aarch64)
18+
endif
19+
20+
.phony: docker/build
21+
docker/build:
22+
docker run --rm debian:10 uname -a
23+
docker run --rm debian:10 uname -a | grep $(ARCH)
24+
docker build -f $(DOCKERFILE) -t $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)-$(ARCH) .
25+
26+
.phony: docker/archive
27+
docker/archive:
28+
docker build -f $(DOCKERFILE) -o out.$(RELEASE_VERSION)-$(LIBC)-$(ARCH) .
29+
tar -czvf pyroscope.$(RELEASE_VERSION)-$(LIBC)-$(ARCH).tar.gz -C out.$(RELEASE_VERSION)-$(LIBC)-$(ARCH) .
30+
31+
.phony: docker/push
32+
docker/push:
33+
docker push $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)-$(ARCH)
34+
35+
.phony: docker/manifest
36+
docker/manifest:
37+
docker manifest create \
38+
$(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC) \
39+
--amend $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)-x86_64 \
40+
--amend $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)-aarch64
41+
docker manifest push $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)
42+
43+
docker manifest create \
44+
$(DOCKER_IMAGE):latest-$(LIBC) \
45+
--amend $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)-x86_64 \
46+
--amend $(DOCKER_IMAGE):$(RELEASE_VERSION)-$(LIBC)-aarch64
47+
docker manifest push $(DOCKER_IMAGE):latest-$(LIBC)
48+

Pyroscope.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ ADD shared shared
1111
ADD CMakeLists.txt CMakeLists.txt
1212

1313
RUN mkdir build-release && cd build-release && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
14-
RUN cd build-release && make -j6 Datadog.Profiler.Native Datadog.Linux.ApiWrapper.x64
14+
RUN cd build-release && make -j16 Datadog.Profiler.Native Datadog.Linux.ApiWrapper.x64
1515

1616
FROM scratch
17-
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-x64/Datadog.Profiler.Native.so /Pyroscope.Profiler.Native.so
18-
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-x64/Datadog.Linux.ApiWrapper.x64.so /Pyroscope.Linux.ApiWrapper.x64.so
17+
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux/Datadog.Profiler.Native.so /Pyroscope.Profiler.Native.so
18+
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux/Datadog.Linux.ApiWrapper.x64.so /Pyroscope.Linux.ApiWrapper.x64.so

Pyroscope.musl.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ ADD shared shared
2828
ADD CMakeLists.txt CMakeLists.txt
2929

3030
RUN mkdir build-release && cd build-release && cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
31-
RUN cd build-release && make -j6 Datadog.Profiler.Native Datadog.Linux.ApiWrapper.x64
31+
RUN cd build-release && make -j16 Datadog.Profiler.Native Datadog.Linux.ApiWrapper.x64
3232

3333
FROM scratch
34-
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl-x64/Datadog.Profiler.Native.so /Pyroscope.Profiler.Native.so
35-
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl-x64/Datadog.Linux.ApiWrapper.x64.so /Pyroscope.Linux.ApiWrapper.x64.so
34+
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl/Datadog.Profiler.Native.so /Pyroscope.Profiler.Native.so
35+
COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl/Datadog.Linux.ApiWrapper.x64.so /Pyroscope.Linux.ApiWrapper.x64.so

Pyroscope/Pyroscope/Pyroscope.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
8-
<PackageVersion>0.8.6</PackageVersion>
9-
<AssemblyVersion>0.8.6</AssemblyVersion>
10-
<FileVersion>0.8.6</FileVersion>
8+
<PackageVersion>0.8.7</PackageVersion>
9+
<AssemblyVersion>0.8.7</AssemblyVersion>
10+
<FileVersion>0.8.7</FileVersion>
1111
<LangVersion>10</LangVersion>
1212
</PropertyGroup>
1313

profiler/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ if (DEFINED ENV{IsAlpine} AND "$ENV{IsAlpine}" MATCHES "true")
105105
SET(ARCH_BASENAME "${ARCH_BASENAME}-musl")
106106
endif()
107107

108-
SET(DEPLOY_DIR ${OUTPUT_BUILD_DIR}/DDProf-Deploy/${ARCH_BASENAME}-${ARCH_POSTFIX})
108+
SET(DEPLOY_DIR ${OUTPUT_BUILD_DIR}/DDProf-Deploy/${ARCH_BASENAME})
109109

110110
# Set output folders
111111
SET(OUTPUT_TMP_DIR ${CMAKE_BINARY_DIR}/tmp.${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})

0 commit comments

Comments
 (0)