-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathDockerfile.linuxcross
More file actions
46 lines (36 loc) · 1.61 KB
/
Dockerfile.linuxcross
File metadata and controls
46 lines (36 loc) · 1.61 KB
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
FROM ubuntu:jammy AS build
USER root:root
WORKDIR /root/pkg-fetch/
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y curl software-properties-common ca-certificates gnupg
# Install Node.js 20
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
RUN apt-get install -y binutils g++-12 git make patch python3 python3-setuptools
# For armv7, we use "arm" as TARGET_TOOLCHAIN_ARCH
# which will translate to arm-linux-gnueabihf toolchain
ARG TARGET_TOOLCHAIN_ARCH=arm
# Only install cross-compilation toolchain if we're not already on the target architecture
# When building with --platform linux/arm/v7, dpkg --print-architecture returns "armhf"
RUN if ! dpkg --print-architecture | grep -q armhf; then \
apt-get install -y binutils-${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf g++-12-${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf; \
fi
ENV CC=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-gcc-12
ENV CXX=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-g++-12
ENV AR=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-ar
ENV NM=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-nm
ENV RANLIB=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-ranlib
ENV READELF=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-readelf
ENV STRIP=${TARGET_TOOLCHAIN_ARCH}-linux-gnueabihf-strip
ENV CC_host=gcc-12
ENV CXX_host=g++-12
ENV AR_host=ar
ENV NM_host=nm
ENV RANLIB_host=ranlib
ENV READELF_host=readelf
ARG PKG_FETCH_OPTION_a=armv7
ARG PKG_FETCH_OPTION_n
RUN mkdir -p dist && npx @yao-pkg/pkg-fetch --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --output dist
FROM scratch
COPY --from=build /root/pkg-fetch/dist /