From 2cefc35842617e6a33528adb30f96a5bfbc06bd5 Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Tue, 3 Sep 2024 09:56:51 +0000 Subject: [PATCH] =?UTF-8?q?Docker=20=E5=A4=9A=E5=B9=B3=E5=8F=B0=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Dockerfile | 33 +++++++++++++++++++++++++-------- build/cargo_config | 5 +++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 build/cargo_config diff --git a/build/Dockerfile b/build/Dockerfile index d6e66e5b..f23e01e2 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,17 +1,34 @@ -FROM python:3.12.0rc2-slim-bookworm as builder +# syntax = docker/dockerfile:experimental +FROM python:3.12.0rc2-slim-bookworm AS builder + +ARG TARGETARCH RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list.d/debian.sources \ && apt-get update \ - && apt-get install -y --no-install-recommends build-essential libevent-dev libjpeg-dev libbsd-dev git pkg-config \ - && rm -rf /var/lib/apt/lists/* + && apt-get install -y --no-install-recommends build-essential libssl-dev libffi-dev python3-dev libevent-dev libjpeg-dev libbsd-dev git pkg-config wget curl -RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \ - && pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check build \ - && pip wheel --wheel-dir=/tmp/wheel/ aiofiles aiohttp appdirs asn1crypto async_lru async-timeout bottle cffi chardet click colorama cryptography \ +COPY build/cargo_config /tmp/config + +RUN --security=insecure pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \ + && if [ "${TARGETARCH}" = "arm" ]; then \ + mkdir -p /root/.cargo \ + && chmod 777 /root/.cargo && mount -t tmpfs none /root/.cargo \ + && export RUSTUP_DIST_SERVER="https://mirrors.tuna.tsinghua.edu.cn/rustup" \ + && export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup" \ + && wget https://sh.rustup.rs -O /root/rustup-init.sh \ + && sh /root/rustup-init.sh -y \ + && export PATH=$PATH:/root/.cargo/bin \ + && cp /tmp/config /root/.cargo/config.toml \ + && pip wheel --wheel-dir=/tmp/wheel/ cryptography; \ + else \ + pip wheel --wheel-dir=/tmp/wheel/ cryptography; \ + fi; + +RUN pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-check build \ + && pip wheel --wheel-dir=/tmp/wheel/ aiofiles aiohttp appdirs asn1crypto async_lru async-timeout bottle cffi chardet click colorama \ dbus_next gpiod hidapi idna mako marshmallow more-itertools multidict netifaces packaging passlib pillow ply psutil pycparser \ pyelftools pyghmi pygments pyparsing pyotp qrcode requests semantic-version setproctitle setuptools six spidev \ - tabulate urllib3 wrapt xlib yarl pyserial pyyaml zstandard supervisor \ - && pip cache purge + tabulate urllib3 wrapt xlib yarl pyserial pyyaml zstandard supervisor RUN git clone --depth=1 https://gh.xmly.dev/https://github.com/pikvm/ustreamer /tmp/ustreamer \ #&& git clone --depth=1 https://github.com/pikvm/ustreamer /tmp/ustreamer \ diff --git a/build/cargo_config b/build/cargo_config new file mode 100644 index 00000000..7e96e143 --- /dev/null +++ b/build/cargo_config @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = 'ustc' + +[source.ustc] +registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/" \ No newline at end of file