Closed Nelocompne closed 11 months ago
install cmake
in your image
you'll probably need to install Go
too
it can potentially be useful for https://github.com/Watfaq/clash-rs/issues/90
I did some rough handling.
Successfully compiled and running.(only linux x86_64)
now Dockerfile
looks like this:
FROM --platform=${BUILDPLATFORM} debian:bullseye as dep
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl ca-certificates \
cmake golang \
clang lld build-essential nasm && \
rm -rf /var/lib/apt/lists/* && \
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --no-modify-path --profile minimal
ENV PATH="/root/.cargo/bin:$PATH"
FROM dep as builder
WORKDIR /workdir
COPY . .
RUN git clone https://github.com/google/boringssl deps/boringssl/src
RUN --mount=type=cache,target=/root/.cargo/git/db \
--mount=type=cache,target=/root/.cargo/registry/cache \
--mount=type=cache,target=/root/.cargo/registry/index \
cargo fetch
RUN --mount=type=cache,target=/root/.cargo/git/db \
--mount=type=cache,target=/root/.cargo/registry/cache \
--mount=type=cache,target=/root/.cargo/registry/index \
cargo fix --lib -p clash_lib --allow-no-vcs && \
rustup target add x86_64-unknown-linux-gnu && \
cargo build -p clash --target x86_64-unknown-linux-gnu --release && \
ls -l ./target/x86_64-unknown-linux-gnu/release && \
mv ./target/x86_64-unknown-linux-gnu/release/clash /clash-rs
FROM debian:bullseye-slim
RUN apt-get update && rm -rf /var/lib/apt/lists/*
COPY --from=builder /clash-rs /usr/local/bin/clash-rs
ENTRYPOINT ["clash-rs"]
As you can see I had to manually pull boringssl
sub models and fix clash_lib
to complete the compilation. And this dockerfile is only valid for x86 compilation.
the aarch64 compilation tells me an error in boringtun
: linking with 'cc' failed: exit status: 1
,
probably something to do with glibc
. I don't know much about these, but I'll keep an eye out.
FROM --platform=${BUILDPLATFORM} debian:bullseye as dep
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl ca-certificates \
cmake golang \
clang lld build-essential nasm && \
rm -rf /var/lib/apt/lists/* && \
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --no-modify-path --profile minimal
ENV PATH="/root/.cargo/bin:$PATH"
FROM dep as builder
WORKDIR /workdir
COPY . .
RUN git submodule init && git submodule foreach git pull origin master && git submodule update
RUN --mount=type=cache,target=/root/.cargo/git/db \
--mount=type=cache,target=/root/.cargo/registry/cache \
--mount=type=cache,target=/root/.cargo/registry/index \
cargo fetch
ENV TARGET=aarch64-unknown-linux-gnu
RUN --mount=type=cache,target=/root/.cargo/git/db \
--mount=type=cache,target=/root/.cargo/registry/cache \
--mount=type=cache,target=/root/.cargo/registry/index \
rustup target add $TARGET && \
cargo build -p clash --target $TARGET --release && \
ls -l ./target/$TARGET/&& \
mv ./target/$TARGET/release/clash /clash-rs
FROM debian:bullseye-slim
RUN apt-get update && rm -rf /var/lib/apt/lists/*
COPY --from=builder /clash-rs /usr/local/bin/clash-rs
ENTRYPOINT ["clash-rs"]
this one builds with podman build --platform=linux/arm64 .
hope it helps somehow
if you'd like to do cross compile, maybe take a look at this https://github.com/briansmith/ring/blob/main/BUILDING.md#supported-toolchains-and-cross-compiling
Dockerfile is possible. there are just some problems with cross-compile, so I closed the issuse.
I am make this
Dockerfile
then
docker build . -t name
output error:
I don't know if Docker containers are in your plans, I tried simply creating a docker build with no success, I'm wondering if this is a related dependency issue? Or is there something wrong with my dockerfile?
Thank you for your work.