Skip to content

Commit 41fd615

Browse files
authored
Merge pull request #65 from Chia-Network/EL.alpine
Add alpine container for musl wheel builds
2 parents d351bd7 + 4bf4e2b commit 41fd615

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

.github/workflows/build-alpine.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Alpine Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "alpine/*"
9+
- ".github/workflows/build-alpine.yml"
10+
pull_request:
11+
paths:
12+
- "alpine/*"
13+
- ".github/workflows/build-alpine.yml"
14+
workflow_dispatch:
15+
schedule:
16+
- cron: "30 12 * * 5"
17+
18+
concurrency:
19+
# SHA is added to the end if on `main` to let all main workflows run
20+
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
build:
25+
uses: Chia-Network/actions/.github/workflows/docker-build.yaml@main
26+
with:
27+
alternate-latest-mode: true
28+
docker-context: "./alpine"
29+
docker-platforms: linux/amd64
30+
dockerfile: "./alpine/Dockerfile"
31+
dockerhub_imagename: "chianetwork/alpine-builder"
32+
image_subpath: "alpine-builder"
33+
secrets:
34+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
35+
DOCKERHUB_PAT: ${{ secrets.DOCKERHUB_PAT }}

alpine/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM alpine:3.16.2
2+
WORKDIR /root
3+
4+
# Set environment variables for rust and pyenv
5+
ENV PYENV_ROOT=/root/.pyenv
6+
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
7+
ENV PATH="/root/.cargo/bin:${PATH}"
8+
ENV RUST_BACKTRACE=1
9+
10+
RUN sh -c "echo https://mirrors.edge.kernel.org/alpine/v3.16.2/community >> /etc/apk/repositories"
11+
RUN apk add bash git curl python3 openssl openssl-dev perl linux-headers make gcc musl-dev patch patchelf
12+
# Additional pyenv dependencies
13+
RUN apk add --no-cache build-base libffi-dev bzip2-dev zlib-dev xz-dev readline-dev sqlite-dev tk-dev
14+
15+
# Install Rust
16+
RUN curl --proto '=https' --tlsv1.2 -sSf -o rustup https://sh.rustup.rs
17+
RUN sh ./rustup -y
18+
19+
# Build a copy of openssl - needed for the rust-openssl crate
20+
COPY build-openssl.sh .
21+
RUN sh ./build-openssl.sh
22+
23+
RUN curl https://pyenv.run | bash && \
24+
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.8 && \
25+
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.9 && \
26+
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.10 && \
27+
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.11 && \
28+
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.12

alpine/build-openssl.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm
4+
ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic
5+
ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
6+
7+
mkdir /musl
8+
9+
wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1w.tar.gz
10+
tar zxvf OpenSSL_1_1_1w.tar.gz
11+
cd openssl-OpenSSL_1_1_1w/ || exit
12+
13+
CC="/usr/bin/x86_64-alpine-linux-musl-gcc -static" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64
14+
make depend
15+
make -j"$(nproc)"
16+
make install

0 commit comments

Comments
 (0)