-
Notifications
You must be signed in to change notification settings - Fork 568
/
Dockerfile.build-musl
56 lines (50 loc) · 1.99 KB
/
Dockerfile.build-musl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Multi-arch build (local):
# docker buildx create --use --driver=docker-container --name container --bootstrap
# docker buildx build . --cache-to type=local,dest=.cache,mode=max --cache-from type=local,src=.cache --platform=linux/amd64 --builder=container --progress plain -o dist -f Dockerfile.build-musl
# ,linux/arm64,linux/arm/v7
# rust links from https://forge.rust-lang.org/infra/other-installation-methods.html#standalone-installers
# map source image to base
FROM python:3.12-alpine3.19 AS base
ARG TARGETARCH
ARG TARGETVARIANT
WORKDIR /app
RUN \
--mount=type=cache,target=/var/cache/apk,sharing=shared \
apk update && \
apk add git curl binutils gcc libc-dev libffi-dev zlib-dev openssl-dev tzdata bash patchelf python3-dev musl-dev pkgconfig cargo
# from https://cryptography.io/en/latest/installation/#building-cryptography-on-linux
# If you get an error with openssl-dev you may have to use libressl-dev.
# cargo
FROM base AS base_amd64_none
# does not need rustc
FROM base AS base_arm64_none
# does not need rustc
FROM base AS base_arm_v7
# does not have musl variant prepackaged but the one from apk works
FROM base_${TARGETARCH}_${TARGETVARIANT:-none} AS builder
ARG TARGETARCH
ARG TARGETVARIANT
ARG QEMU_CPU
WORKDIR /app
COPY LICENSE.md .
COPY README_PYPI.md .
COPY scripts scripts/
COPY binary_dist binary_dist/
COPY pyproject.toml .
COPY src src/
# staticx must be installed after scons
# staticx gives error: Error relocating /tmp/staticx-pyi-9b5nvfi_/_cffi_backend.cpython-312-x86_64-linux-musl.so: PyNumber_Long: symbol not found, so not using for musl
RUN \
--mount=type=cache,target=/root/.cache/pip,sharing=shared \
python3 -m venv .venv && \
. .venv/bin/activate && \
pip3 install --disable-pip-version-check .[dev,devlinux]
RUN \
. .venv/bin/activate && \
scripts/build_bin2 icloudpd icloud && \
scripts/build_bin1 icloud && \
scripts/build_bin1 icloudpd_ex && \
scripts/build_whl
FROM scratch
WORKDIR /
COPY --from=builder /app/dist/icloud* .