Skip to content

Commit

Permalink
Merge pull request #65 from Chia-Network/EL.alpine
Browse files Browse the repository at this point in the history
Add alpine container for musl wheel builds
  • Loading branch information
Starttoaster authored Jan 29, 2024
2 parents d351bd7 + 4bf4e2b commit 41fd615
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build Alpine Image

on:
push:
branches:
- main
paths:
- "alpine/*"
- ".github/workflows/build-alpine.yml"
pull_request:
paths:
- "alpine/*"
- ".github/workflows/build-alpine.yml"
workflow_dispatch:
schedule:
- cron: "30 12 * * 5"

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
cancel-in-progress: true

jobs:
build:
uses: Chia-Network/actions/.github/workflows/docker-build.yaml@main
with:
alternate-latest-mode: true
docker-context: "./alpine"
docker-platforms: linux/amd64
dockerfile: "./alpine/Dockerfile"
dockerhub_imagename: "chianetwork/alpine-builder"
image_subpath: "alpine-builder"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PAT: ${{ secrets.DOCKERHUB_PAT }}
28 changes: 28 additions & 0 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM alpine:3.16.2
WORKDIR /root

# Set environment variables for rust and pyenv
ENV PYENV_ROOT=/root/.pyenv
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
ENV PATH="/root/.cargo/bin:${PATH}"
ENV RUST_BACKTRACE=1

RUN sh -c "echo https://mirrors.edge.kernel.org/alpine/v3.16.2/community >> /etc/apk/repositories"
RUN apk add bash git curl python3 openssl openssl-dev perl linux-headers make gcc musl-dev patch patchelf
# Additional pyenv dependencies
RUN apk add --no-cache build-base libffi-dev bzip2-dev zlib-dev xz-dev readline-dev sqlite-dev tk-dev

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf -o rustup https://sh.rustup.rs
RUN sh ./rustup -y

# Build a copy of openssl - needed for the rust-openssl crate
COPY build-openssl.sh .
RUN sh ./build-openssl.sh

RUN curl https://pyenv.run | bash && \
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.8 && \
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.9 && \
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.10 && \
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.11 && \
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --skip-existing 3.12
16 changes: 16 additions & 0 deletions alpine/build-openssl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm
ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic
ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux

mkdir /musl

wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1w.tar.gz
tar zxvf OpenSSL_1_1_1w.tar.gz
cd openssl-OpenSSL_1_1_1w/ || exit

CC="/usr/bin/x86_64-alpine-linux-musl-gcc -static" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64
make depend
make -j"$(nproc)"
make install

0 comments on commit 41fd615

Please sign in to comment.