Skip to content

Commit 1fe9121

Browse files
authored
ci: use Alpine Linux Docker image (#1261)
1 parent 0ad2977 commit 1fe9121

File tree

4 files changed

+97
-24
lines changed

4 files changed

+97
-24
lines changed

.github/docker/alpine/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# docker build --build-arg BASE=alpine:3.21
2+
ARG BASE=alpine:latest
3+
FROM ${BASE}
4+
5+
RUN apk update
6+
RUN apk add \
7+
bash \
8+
build-base \
9+
cargo \
10+
clang \
11+
cmake \
12+
curl \
13+
file \
14+
git \
15+
icu \
16+
linux-headers \
17+
lsb-release-minimal \
18+
mitmproxy \
19+
moreutils \
20+
perl \
21+
powershell \
22+
python3 \
23+
python3-dev \
24+
py3-pip \
25+
sudo \
26+
tar \
27+
tree \
28+
wget
29+
30+
RUN curl -sSL --retry 5 https://dot.net/v1/dotnet-install.sh | bash -eo pipefail /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet
31+
RUN ln -s /usr/share/dotnet/dotnet /usr/local/bin/dotnet
32+
33+
# https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-python.sh
34+
COPY pip.conf /etc/pip.conf
35+
ENV PIPX_BIN_DIR=/opt/pipx_bin
36+
ENV PIPX_HOME=/opt/pipx
37+
RUN python3 -m pip install pipx
38+
RUN python3 -m pipx ensurepath
39+
ENV PATH="PIPX_BIN_DIR:$PATH"

.github/docker/alpine/pip.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[global]
2+
break-system-packages = true

.github/workflows/ci.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ jobs:
8888
RUN_ANALYZER: code-checker,valgrind
8989
- name: Linux (GCC + musl + libunwind)
9090
os: ubuntu-latest
91-
container: alpine:3.21
92-
APK_PACKAGES: libunwind-dev libunwind-static
91+
container: ghcr.io/getsentry/sentry-native-alpine:3.21
9392
CMAKE_DEFINES: -DSENTRY_LIBUNWIND_SHARED=OFF
9493
CC: gcc
9594
CXX: g++
95+
SYSTEM_PYTHON: 1
9696
- name: Linux (clang + musl + libunwind)
9797
os: ubuntu-latest
98-
container: alpine:3.21
99-
APK_PACKAGES: clang libunwind-dev libunwind-static
98+
container: ghcr.io/getsentry/sentry-native-alpine:3.21
10099
CMAKE_DEFINES: -DSENTRY_LIBUNWIND_SHARED=OFF
101100
CC: clang
102101
CXX: clang++
102+
SYSTEM_PYTHON: 1
103103
- name: macOS 14 (xcode llvm)
104104
os: macos-14
105105
ERROR_ON_WARNINGS: 1
@@ -162,23 +162,15 @@ jobs:
162162
CMAKE_DEFINES: ${{ matrix.CMAKE_DEFINES }}
163163
SYSTEM_VERSION_COMPAT: ${{ matrix.SYSTEM_VERSION_COMPAT }}
164164
VS_GENERATOR_TOOLSET: ${{ matrix.VS_GENERATOR_TOOLSET }}
165+
SYSTEM_PYTHON: ${{ matrix.SYSTEM_PYTHON }}
165166

166167
steps:
167-
- name: Installing Alpine Linux Dependencies
168-
if: ${{ contains(matrix.container, 'alpine') }}
169-
run: |
170-
apk update
171-
apk add bash build-base cargo cmake curl curl-dev git icu linux-headers mitmproxy perl python3-dev sudo xz-dev ${{ matrix.APK_PACKAGES }}
172-
curl -sSL --retry 5 https://dot.net/v1/dotnet-install.sh | bash -eo pipefail /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet
173-
ln -s /usr/share/dotnet/dotnet /usr/local/bin/dotnet
174-
175168
- uses: actions/checkout@v4
176169
with:
177170
submodules: recursive
178171
- uses: actions/setup-python@v5
179-
if: ${{ !matrix.container }}
180172
with:
181-
python-version: "3.11"
173+
python-version: ${{ !env['SYSTEM_PYTHON'] && '3.11' || '' }}
182174
cache: "pip"
183175

184176
- name: Installing Linux Dependencies
@@ -210,6 +202,12 @@ jobs:
210202
sudo apt update
211203
sudo apt install cmake gcc-9-multilib g++-9-multilib zlib1g-dev:i386 libssl-dev:i386 libcurl4-openssl-dev:i386
212204
205+
- name: Installing Alpine Linux Dependencies
206+
if: ${{ contains(matrix.container, 'alpine') }}
207+
run: |
208+
apk update
209+
apk add curl-dev libunwind-dev libunwind-static xz-dev
210+
213211
# https://github.com/actions/runner-images/issues/9491
214212
- name: Decrease vm.mmap_rnd_bit to prevent ASLR ASAN issues
215213
if: ${{ runner.os == 'Linux' && contains(env['RUN_ANALYZER'], 'asan') }}
@@ -274,19 +272,11 @@ jobs:
274272
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
275273
run: |
276274
echo "127.0.0.1 sentry.native.test" | sudo tee -a /etc/hosts
275+
# remove "::1 localhost ..." to avoid conflicts with proxy tests (musl)
276+
sed '/^::1/d' /etc/hosts | sudo tee /etc/hosts
277277
cat /etc/hosts
278278
shell: bash
279279

280-
- name: Prepare env for Alpine Linux
281-
if: ${{ contains(matrix.container, 'alpine') }}
282-
run: |
283-
apk add moreutils
284-
# comment out "::1 localhost ..." to avoid conflicts with proxy tests
285-
sed '/^::1/ s/^/#/' /etc/hosts | sponge /etc/hosts
286-
python3 -m venv .venv --system-site-packages
287-
source .venv/bin/activate
288-
echo "PATH=$PATH" >> $GITHUB_ENV
289-
290280
- name: Test
291281
shell: bash
292282
run: |

.github/workflows/docker.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '.github/docker/**'
9+
workflow_dispatch:
10+
11+
jobs:
12+
alpine:
13+
name: Build alpine:${{ matrix.version }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
version:
19+
- '3.21'
20+
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
env:
26+
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/sentry-native-alpine:${{ matrix.version }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Build ${{ env.IMAGE_NAME }}
38+
run: docker build --build-arg BASE=alpine:${{ matrix.version }} -t ${{ env.IMAGE_NAME }} .
39+
working-directory: .github/docker/alpine
40+
41+
- name: Push ${{ env.IMAGE_NAME }}
42+
run: docker push ${{ env.IMAGE_NAME }}

0 commit comments

Comments
 (0)