Watfaq / clash-rs

custom protocol network proxy
https://watfaq.gitbook.io/clashrs-user-manual/
Apache License 2.0
781 stars 62 forks source link

try Dockerfile build binary #162

Closed Nelocompne closed 11 months ago

Nelocompne commented 11 months ago

I am make this Dockerfile

FROM rust:latest as builder
WORKDIR /workdir
COPY . .

RUN chmod +x ./scripts/build.sh && \
    sh ./scripts/build.sh x86_64-unknown-linux-gnu && \
    cp ./target/artifacts/clash-x86_64-unknown-linux-gnu /usr/local/cargo/bin/clash-rs

FROM debian:bullseye-slim
RUN apt-get update && apt-get install -y cmake && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/clash-rs /usr/local/bin/clash-rs
CMD ["clash-rs", "--version"]

then docker build . -t name

output error:

 => ERROR [builder 4/4] RUN chmod +x ./scripts/build.sh &&     sh ./scripts/build.sh x86_64-unknown-linux-gnu &&     cp ./target/artifacts/cla  174.6s
------
 > [builder 4/4] RUN chmod +x ./scripts/build.sh &&     sh ./scripts/build.sh x86_64-unknown-linux-gnu &&     cp ./target/artifacts/clash-x86_64-unknown-linux-gnu /usr/local/cargo/bin/clash-rs:
0.189 + [ ! -d target/artifacts ]
0.189 + mkdir -p target/artifacts
0.191 + echo x86_64-unknown-linux-gnu
0.192 + tr -d \n
0.192 + tr -d \r
0.192 + tr -d [:space:]
0.193 + TARGET=x86_64-unknown-linux-gnu
0.193 + echo building for x86_64-unknown-linux-gnu
0.193 + rustup target add x86_64-unknown-linux-gnu
0.193 building for x86_64-unknown-linux-gnu
0.283 info: component 'rust-std' for target 'x86_64-unknown-linux-gnu' is up to date
0.285 + cargo build -p clash --target x86_64-unknown-linux-gnu --release
0.383     Updating crates.io index
1.570     Updating git repository `https://github.com/Watfaq/boring.git`
5.109     Updating git submodule `https://github.com/google/boringssl.git`
57.70     Updating git submodule `https://github.com/google/boringssl.git`
110.1     Updating git repository `https://github.com/Watfaq/netstack-lwip.git`
118.5     Updating git repository `https://github.com/Watfaq/shadowsocks-rust.git`
123.5     Updating git repository `https://github.com/Watfaq/rust-tun.git`
129.6  Downloading crates ...
131.2   Downloaded alloc-stdlib v0.2.2
131.6   Downloaded time v0.3.29
131.6   Downloaded form_urlencoded v1.2.0
131.6   Downloaded foreign-types-shared v0.3.1
131.6   Downloaded ctr v0.9.2
131.6   Downloaded same-file v1.0.6
131.6   Downloaded crypto-common v0.1.6
131.6   Downloaded match_cfg v0.1.0
131.6   Downloaded shadowsocks-crypto v0.5.1
131.7   Downloaded rustc_version v0.4.0
131.7   Downloaded pin-utils v0.1.0
131.7   Downloaded dhcproto v0.10.0
131.7   Downloaded byte_string v1.0.0
131.7   Downloaded anstyle-parse v0.2.1
131.7   Downloaded pin-project-lite v0.2.13
131.8   Downloaded ecdsa v0.14.8
131.8   Downloaded anyhow v1.0.75
131.8   Downloaded elliptic-curve v0.12.3
131.8   Downloaded tokio-util v0.7.10
131.9   Downloaded ip_network_table v0.2.0
131.9   Downloaded hyper v0.14.27
131.9   Downloaded headers-core v0.2.0
131.9   Downloaded clap v2.34.0
131.9   Downloaded instant v0.1.12
131.9   Downloaded rustls v0.21.8
131.9   Downloaded peeking_take_while v0.1.2
131.9   Downloaded regex-syntax v0.6.29
132.0   Downloaded regex-syntax v0.8.2
132.0   Downloaded lazycell v1.3.0
132.0   Downloaded inotify-sys v0.1.5
132.0   Downloaded axum-core v0.3.4
132.0   Downloaded spin v0.5.2
132.0   Downloaded tracing v0.1.40
132.0   Downloaded time-core v0.1.2
132.0   Downloaded ed25519 v1.5.3
132.0   Downloaded rand v0.8.5
132.0   Downloaded equivalent v1.0.1
132.0   Downloaded itertools v0.11.0
132.0   Downloaded endian-type v0.1.2
132.0   Downloaded fnv v1.0.7
132.0   Downloaded itoa v1.0.9
132.1   Downloaded ioctl-sys v0.8.0
132.1   Downloaded matches v0.1.10
132.1   Downloaded enum-as-inner v0.6.0
132.1   Downloaded textwrap v0.11.0
132.1   Downloaded futures-task v0.3.29
132.1   Downloaded tower-layer v0.3.2
132.1   Downloaded deranged v0.3.8
132.1   Downloaded anstyle v1.0.3
132.1   Downloaded enum-as-inner v0.5.1
132.1   Downloaded matchit v0.7.3
132.1   Downloaded data-encoding v2.4.0
132.1   Downloaded humantime v2.1.0
132.1   Downloaded prost-derive v0.12.1
132.1   Downloaded inotify v0.9.6
132.1   Downloaded async-trait v0.1.74
132.1   Downloaded parking_lot_core v0.9.8
132.1   Downloaded which v4.4.2
132.1   Downloaded network-interface v1.1.1
132.1   Downloaded lru-cache v0.1.2
132.1   Downloaded bitflags v1.3.2
132.1   Downloaded murmur3 v0.5.2
132.1   Downloaded glob v0.3.1
132.1   Downloaded http-body v0.4.5
132.1   Downloaded num_cpus v1.16.0
132.1   Downloaded blake2 v0.10.6
132.1   Downloaded unicode-bidi v0.3.13
132.1   Downloaded proc-macro2 v1.0.67
132.1   Downloaded base64 v0.13.1
132.1   Downloaded tower-http v0.4.4
132.2   Downloaded ppv-lite86 v0.2.17
132.2   Downloaded home v0.5.5
132.2   Downloaded rand_chacha v0.3.1
132.2   Downloaded version_check v0.9.4
132.2   Downloaded percent-encoding v2.3.0
132.2   Downloaded curve25519-dalek v4.0.0-rc.3
132.2   Downloaded fslock v0.2.1
132.2   Downloaded serde_yaml v0.9.27
132.2   Downloaded boringtun v0.6.0
132.2   Downloaded foreign-types-macros v0.2.3
132.2   Downloaded memchr v2.6.3
132.2   Downloaded integer-encoding v3.0.4
132.2   Downloaded linked-hash-map v0.5.6
132.2   Downloaded clap_lex v0.6.0
132.2   Downloaded zeroize v1.6.0
132.2   Downloaded errno v0.3.3
132.2   Downloaded futures-sink v0.3.29
132.2   Downloaded untrusted v0.9.0
132.2   Downloaded rustversion v1.0.14
132.2   Downloaded arrayref v0.3.7
132.2   Downloaded either v1.9.0
132.3   Downloaded linux-raw-sys v0.4.10
132.3   Downloaded urlencoding v2.1.3
132.3   Downloaded quote v1.0.33
132.3   Downloaded h2 v0.3.21
132.3   Downloaded hashbrown v0.12.3
132.3   Downloaded state v0.6.0
132.3   Downloaded crypto-bigint v0.4.9
132.3   Downloaded hex v0.4.3
132.3   Downloaded tokio-stream v0.1.14
132.3   Downloaded ryu v1.0.15
132.4   Downloaded clap_derive v4.4.7
132.4   Downloaded nu-ansi-term v0.46.0
132.4   Downloaded ordered-float v2.10.0
132.4   Downloaded pin-project v1.1.3
132.4   Downloaded sha2 v0.10.8
132.4   Downloaded want v0.3.1
132.4   Downloaded indexmap v1.9.3
132.4   Downloaded opentelemetry-jaeger v0.19.0
132.4   Downloaded atty v0.2.14
132.4   Downloaded semver v1.0.19
132.4   Downloaded sec1 v0.3.0
132.4   Downloaded nix v0.25.1
132.4   Downloaded tokio-tfo v0.2.2
132.4   Downloaded idna v0.4.0
132.4   Downloaded syn v1.0.109
132.5   Downloaded utf-8 v0.7.6
132.5   Downloaded radix_trie v0.2.1
132.5   Downloaded x25519-dalek v2.0.0-rc.3
132.5   Downloaded ip_network_table-deps-treebitmap v0.5.0
132.5   Downloaded hashbrown v0.14.0
132.5   Downloaded hickory-client v0.24.0
132.5   Downloaded chacha20poly1305 v0.10.1
132.5   Downloaded lock_api v0.4.10
132.5   Downloaded opentelemetry_api v0.20.0
132.5   Downloaded ipnetwork v0.18.0
132.5   Downloaded ghash v0.5.0
132.5   Downloaded curve25519-dalek-derive v0.1.0
132.5   Downloaded unicode-width v0.1.11
132.5   Downloaded bytes v1.5.0
132.5   Downloaded arc-swap v1.6.0
132.5   Downloaded time-macros v0.2.15
132.5   Downloaded trust-dns-resolver v0.23.0
132.5   Downloaded opentelemetry-http v0.9.0
132.5   Downloaded idna v0.2.3
132.5   Downloaded clang-sys v1.6.1
132.5   Downloaded bitflags v2.4.0
132.5   Downloaded socket2 v0.4.9
132.5   Downloaded utf8parse v0.2.1
132.5   Downloaded opentelemetry v0.20.0
132.6   Downloaded opaque-debug v0.3.0
132.6   Downloaded erased-serde v0.3.31
132.6   Downloaded httpdate v1.0.3
132.6   Downloaded walkdir v2.4.0
132.6   Downloaded http-range-header v0.3.1
132.6   Downloaded overload v0.1.1
132.6   Downloaded strsim v0.8.0
132.6   Downloaded sharded-slab v0.1.4
132.6   Downloaded thiserror-impl v1.0.50
132.6   Downloaded url v2.4.1
132.6   Downloaded base64 v0.21.5
132.6   Downloaded der v0.6.1
132.6   Downloaded crossbeam-channel v0.5.8
132.6   Downloaded mime v0.3.17
132.6   Downloaded hickory-server v0.24.0
132.6   Downloaded mio v0.8.8
132.6   Downloaded unicode-normalization v0.1.22
132.6   Downloaded opentelemetry-semantic-conventions v0.12.0
132.6   Downloaded nom v7.1.3
132.6   Downloaded serde_json v1.0.107
132.7   Downloaded tokio-tungstenite v0.20.1
132.7   Downloaded serde_derive v1.0.191
132.7   Downloaded threadpool v1.8.1
132.7   Downloaded bindgen v0.66.1
132.7   Downloaded sync_wrapper v0.1.2
132.7   Downloaded p256 v0.11.1
132.7   Downloaded futures-macro v0.3.29
132.7   Downloaded uuid v1.5.0
132.7   Downloaded tinyvec v1.6.0
132.7   Downloaded ipnet v2.9.0
132.7   Downloaded webpki-roots v0.25.2
132.7   Downloaded cc v1.0.83
132.7   Downloaded tungstenite v0.20.1
132.7   Downloaded regex v1.10.2
132.7   Downloaded futures-io v0.3.29
132.7   Downloaded parking_lot_core v0.8.6
132.8   Downloaded rustix v0.38.21
132.8   Downloaded dhcproto-macros v0.1.0
132.8   Downloaded futures v0.3.29
132.8   Downloaded crc32fast v1.3.2
132.8   Downloaded nibble_vec v0.1.0
132.8   Downloaded futures-core v0.3.29
132.8   Downloaded chrono v0.4.31
132.8   Downloaded p384 v0.11.2
132.8   Downloaded regex-automata v0.1.10
132.8   Downloaded thrift v0.17.0
132.8   Downloaded bindgen v0.69.1
132.9   Downloaded resolv-conf v0.7.0
132.9   Downloaded cexpr v0.6.0
132.9   Downloaded thread_local v1.1.7
132.9   Downloaded tracing-core v0.1.32
132.9   Downloaded hkdf v0.12.3
132.9   Downloaded clap_builder v4.4.7
132.9   Downloaded smallvec v1.11.1
132.9   Downloaded trust-dns-proto v0.23.0
132.9   Downloaded ring-compat v0.5.1
132.9   Downloaded libc v0.2.150
133.0   Downloaded parking_lot v0.11.2
133.0   Downloaded blake3 v1.5.0
133.0   Downloaded futures-util v0.3.29
133.0   Downloaded rustls-webpki v0.101.7
133.0   Downloaded thiserror v1.0.50
133.0   Downloaded scopeguard v1.2.0
133.0   Downloaded http v0.2.9
133.0   Downloaded ordered-float v3.9.1
133.0   Downloaded parking_lot v0.12.1
133.0   Downloaded futures-executor v0.3.29
133.0   Downloaded zeroize_derive v1.4.2
133.1   Downloaded byteorder v1.5.0
133.1   Downloaded tinyvec_macros v0.1.1
133.1   Downloaded unsafe-libyaml v0.2.9
133.1   Downloaded tokio-rustls v0.24.1
133.1   Downloaded tokio v1.33.0
133.1   Downloaded typenum v1.17.0
133.1   Downloaded iana-time-zone v0.1.57
133.1   Downloaded brotli-decompressor v2.5.0
133.2   Downloaded trust-dns-proto v0.22.0
133.2   Downloaded libloading v0.7.4
133.2   Downloaded hmac v0.12.1
133.2   Downloaded unicode-ident v1.0.12
133.2   Downloaded brotli v3.4.0
133.2   Downloaded once_cell v1.18.0
133.2   Downloaded num-traits v0.2.16
133.2   Downloaded prettyplease v0.2.15
133.2   Downloaded notify v6.1.1
133.2   Downloaded platforms v3.1.2
133.2   Downloaded headers v0.3.9
133.2   Downloaded linked_hash_set v0.1.4
133.2   Downloaded ip_network v0.4.1
133.3   Downloaded env_logger v0.9.3
133.3   Downloaded hostname v0.3.1
133.3   Downloaded futures-channel v0.3.29
133.3   Downloaded fs_extra v1.3.0
133.3   Downloaded ansi_term v0.12.1
133.3   Downloaded log v0.4.20
133.3   Downloaded httparse v1.8.0
133.3   Downloaded prost v0.12.1
133.3   Downloaded pkcs8 v0.9.0
133.3   Downloaded pin-project-internal v1.1.3
133.3   Downloaded serde_path_to_error v0.1.14
133.3   Downloaded chacha20 v0.9.1
133.3   Downloaded md-5 v0.10.6
133.3   Downloaded matchers v0.1.0
133.3   Downloaded const-oid v0.9.5
133.3   Downloaded polyval v0.6.1
133.3   Downloaded universal-hash v0.5.1
133.3   Downloaded untrusted v0.7.1
133.3   Downloaded strsim v0.10.0
133.3   Downloaded tower-service v0.3.2
133.3   Downloaded tracing-oslog v0.1.2
133.3   Downloaded getrandom v0.2.10
133.3   Downloaded vec_map v0.8.2
133.3   Downloaded block-buffer v0.10.4
133.3   Downloaded uuid-macro-internal v1.5.0
133.3   Downloaded signature v1.6.4
133.3   Downloaded rustc-hash v1.1.0
133.3   Downloaded opentelemetry_sdk v0.20.0
133.4   Downloaded foreign-types v0.5.0
133.4   Downloaded digest v0.10.7
133.4   Downloaded mime_guess v2.0.4
133.4   Downloaded poly1305 v0.8.0
133.4   Downloaded lru_time_cache v0.11.11
133.4   Downloaded heck v0.4.1
133.4   Downloaded hickory-resolver v0.24.0
133.4   Downloaded lazy_static v1.4.0
133.4   Downloaded anstream v0.6.1
133.4   Downloaded minimal-lexical v0.2.1
133.4   Downloaded tracing-subscriber v0.3.17
133.4   Downloaded cfg-if v1.0.0
133.4   Downloaded filetime v0.2.22
133.4   Downloaded public-suffix v0.1.0
133.4   Downloaded bindgen v0.59.2
133.4   Downloaded axum v0.6.20
133.4   Downloaded tracing-opentelemetry v0.21.0
133.4   Downloaded aes v0.8.3
133.4   Downloaded aho-corasick v1.1.1
133.5   Downloaded aes-gcm v0.10.3
133.5   Downloaded maxminddb v0.23.0
133.5   Downloaded serde v1.0.191
133.5   Downloaded socket2 v0.5.5
133.5   Downloaded clap v4.4.7
133.5   Downloaded crossbeam-utils v0.8.16
133.5   Downloaded sct v0.7.0
133.5   Downloaded tokio-macros v2.1.0
133.5   Downloaded alloc-no-stdlib v2.0.4
133.5   Downloaded ring v0.17.5
133.6   Downloaded slab v0.4.9
133.6   Downloaded spin v0.9.8
133.6   Downloaded base64ct v1.6.0
133.6   Downloaded unicase v2.7.0
133.6   Downloaded autocfg v1.1.0
133.6   Downloaded aead v0.5.2
133.6   Downloaded rustls-pemfile v1.0.3
133.6   Downloaded base16ct v0.1.1
133.6   Downloaded ring v0.16.20
133.7   Downloaded async-recursion v1.0.5
133.7   Downloaded spki v0.6.0
133.7   Downloaded cipher v0.4.4
133.7   Downloaded signal-hook-registry v1.4.1
133.8   Downloaded sendfd v0.4.3
133.8   Downloaded antidote v1.0.0
133.8   Downloaded tracing-log v0.1.3
133.8   Downloaded colorchoice v1.0.0
133.8   Downloaded syn v2.0.37
133.8   Downloaded inout v0.1.3
133.8   Downloaded rand_core v0.6.4
133.8   Downloaded try-lock v0.2.4
133.8   Downloaded subtle v2.5.0
133.8   Downloaded generic-array v0.14.7
133.8   Downloaded tracing-attributes v0.1.27
133.8   Downloaded cmake v0.1.50
133.8   Downloaded anstyle-query v1.0.0
133.8   Downloaded sha1 v0.10.6
133.8   Downloaded indexmap v2.0.0
133.8   Downloaded tower v0.4.13
133.8   Downloaded quick-error v1.2.3
133.8   Downloaded tracing-appender v0.2.2
133.8   Downloaded cpufeatures v0.2.9
133.8   Downloaded termcolor v1.3.0
133.8   Downloaded shlex v1.2.0
133.8   Downloaded arrayvec v0.7.4
133.8   Downloaded constant_time_eq v0.3.0
133.8   Downloaded serde_urlencoded v0.7.1
133.8   Downloaded regex-automata v0.4.3
133.9   Downloaded hickory-proto v0.24.0
134.0    Compiling proc-macro2 v1.0.67
134.0    Compiling unicode-ident v1.0.12
134.0    Compiling libc v0.2.150
134.0    Compiling cfg-if v1.0.0
134.0    Compiling autocfg v1.1.0
134.0    Compiling version_check v0.9.4
134.2    Compiling log v0.4.20
134.4    Compiling pin-project-lite v0.2.13
134.5    Compiling smallvec v1.11.1
134.6    Compiling quote v1.0.33
134.8    Compiling syn v2.0.37
134.8    Compiling once_cell v1.18.0
135.0    Compiling lock_api v0.4.10
135.1    Compiling typenum v1.17.0
135.2    Compiling generic-array v0.14.7
135.4    Compiling getrandom v0.2.10
135.5    Compiling rand_core v0.6.4
135.6    Compiling scopeguard v1.2.0
135.8    Compiling bytes v1.5.0
135.8    Compiling memchr v2.6.3
136.3    Compiling cc v1.0.83
136.6    Compiling futures-core v0.3.29
136.7    Compiling parking_lot_core v0.9.8
136.9    Compiling futures-sink v0.3.29
136.9    Compiling crypto-common v0.1.6
137.0    Compiling num_cpus v1.16.0
137.2    Compiling slab v0.4.9
137.2    Compiling futures-channel v0.3.29
137.4    Compiling futures-task v0.3.29
137.5    Compiling parking_lot v0.12.1
137.5    Compiling mio v0.8.8
137.6    Compiling subtle v2.5.0
137.7    Compiling futures-util v0.3.29
138.1    Compiling signal-hook-registry v1.4.1
138.2    Compiling socket2 v0.5.5
138.2    Compiling pin-utils v0.1.0
138.2    Compiling futures-io v0.3.29
138.3    Compiling tracing-core v0.1.32
138.4    Compiling itoa v1.0.9
138.5    Compiling thiserror v1.0.50
138.7    Compiling serde v1.0.191
138.7    Compiling glob v0.3.1
138.9    Compiling percent-encoding v2.3.0
139.0    Compiling ppv-lite86 v0.2.17
139.1    Compiling clang-sys v1.6.1
139.3    Compiling rand_chacha v0.3.1
139.4    Compiling block-buffer v0.10.4
139.5    Compiling digest v0.10.7
139.6    Compiling rand v0.8.5
139.6    Compiling async-trait v0.1.74
139.6    Compiling tokio-macros v2.1.0
139.8    Compiling futures-macro v0.3.29
139.8    Compiling tracing-attributes v0.1.27
140.3    Compiling thiserror-impl v1.0.50
140.5    Compiling tokio v1.33.0
141.4    Compiling tracing v0.1.40
141.6    Compiling serde_derive v1.0.191
141.7    Compiling zeroize_derive v1.4.2
142.4    Compiling zeroize v1.6.0
142.5    Compiling cpufeatures v0.2.9
142.6    Compiling fnv v1.0.7
142.6    Compiling aho-corasick v1.1.1
143.2    Compiling regex-syntax v0.8.2
145.5    Compiling regex-automata v0.4.3
145.7    Compiling http v0.2.9
146.9    Compiling indexmap v1.9.3
147.0    Compiling tinyvec_macros v0.1.1
147.1    Compiling minimal-lexical v0.2.1
147.2    Compiling bitflags v2.4.0
147.4    Compiling libloading v0.7.4
147.5    Compiling regex v1.10.2
147.6    Compiling nom v7.1.3
147.9    Compiling tinyvec v1.6.0
148.6    Compiling hashbrown v0.12.3
148.6    Compiling unicode-normalization v0.1.22
149.1    Compiling cexpr v0.6.0
149.2    Compiling shlex v1.2.0
149.3    Compiling peeking_take_while v0.1.2
149.3    Compiling lazycell v1.3.0
149.3    Compiling lazy_static v1.4.0
149.4    Compiling rustc-hash v1.1.0
149.4    Compiling unicode-bidi v0.3.13
149.4    Compiling form_urlencoded v1.2.0
149.5    Compiling ring v0.16.20
149.7    Compiling idna v0.4.0
150.0    Compiling heck v0.4.1
150.1    Compiling url v2.4.1
150.6    Compiling tokio-util v0.7.10
151.2    Compiling data-encoding v2.4.0
151.3    Compiling either v1.9.0
151.4    Compiling untrusted v0.7.1
151.5    Compiling spin v0.5.2
151.6    Compiling num-traits v0.2.16
151.7    Compiling rustix v0.38.21
152.0    Compiling const-oid v0.9.5
152.1    Compiling crossbeam-utils v0.8.16
152.4    Compiling der v0.6.1
152.5    Compiling ring v0.17.5
153.6    Compiling linux-raw-sys v0.4.10
156.8    Compiling h2 v0.3.21
157.0    Compiling futures-executor v0.3.29
157.2    Compiling inout v0.1.3
157.3    Compiling spin v0.9.8
157.4    Compiling home v0.5.5
157.5    Compiling untrusted v0.9.0
157.6    Compiling ipnet v2.9.0
158.1    Compiling opaque-debug v0.3.0
158.2    Compiling base64 v0.21.5
158.6    Compiling httparse v1.8.0
158.6    Compiling which v4.4.2
158.8    Compiling cipher v0.4.4
158.9    Compiling crossbeam-channel v0.5.8
159.3    Compiling universal-hash v0.5.1
159.3    Compiling unicase v2.7.0
159.4    Compiling tower-service v0.3.2
159.4    Compiling base16ct v0.1.1
159.5    Compiling bindgen v0.66.1
159.5    Compiling rustversion v1.0.14
159.7    Compiling semver v1.0.19
159.9    Compiling sec1 v0.3.0
160.2    Compiling enum-as-inner v0.6.0
160.9    Compiling http-body v0.4.5
161.0    Compiling sha1 v0.10.6
161.2    Compiling crypto-bigint v0.4.9
161.4    Compiling signature v1.6.4
161.4    Compiling anyhow v1.0.75
161.6    Compiling urlencoding v2.1.3
161.7    Compiling rustls v0.21.8
161.9    Compiling linked-hash-map v0.5.6
161.9    Compiling httpdate v1.0.3
162.0    Compiling prettyplease v0.2.15
162.0    Compiling elliptic-curve v0.12.3
162.1    Compiling opentelemetry_api v0.20.0
162.1    Compiling rustls-webpki v0.101.7
163.1    Compiling sct v0.7.0
163.2    Compiling aead v0.5.2
163.3    Compiling cmake v0.1.50
163.3    Compiling fslock v0.2.1
163.4    Compiling atty v0.2.14
163.5    Compiling byteorder v1.5.0
163.6    Compiling regex-syntax v0.6.29
163.6    Compiling match_cfg v0.1.0
163.6    Compiling bitflags v1.3.2
163.6    Compiling unicode-width v0.1.11
163.7    Compiling fs_extra v1.3.0
163.7    Compiling mime v0.3.17
163.9    Compiling try-lock v0.2.4
163.9    Compiling want v0.3.1
163.9    Compiling textwrap v0.11.0
164.0    Compiling hostname v0.3.1
164.1    Compiling rustc_version v0.4.0
164.3    Compiling ecdsa v0.14.8
164.5    Compiling ordered-float v3.9.1
164.8    Compiling tokio-stream v0.1.14
165.1    Compiling regex-automata v0.1.10
166.7    Compiling pin-project-internal v1.1.3
166.9    Compiling socket2 v0.4.9
167.2    Compiling syn v1.0.109
167.6    Compiling tower-layer v0.3.2
167.6    Compiling boring-sys v3.0.4 (https://github.com/Watfaq/boring.git?rev=24c006f#24c006fd)
167.7    Compiling quick-error v1.2.3
167.7    Compiling vec_map v0.8.2
167.8    Compiling ryu v1.0.15
168.0    Compiling bindgen v0.59.2
168.1    Compiling humantime v2.1.0
168.2    Compiling strsim v0.8.0
168.2    Compiling ansi_term v0.12.1
168.4    Compiling bindgen v0.69.1
168.4    Compiling platforms v3.1.2
168.6    Compiling termcolor v1.3.0
168.6    Compiling overload v0.1.1
168.7    Compiling base64ct v1.6.0
168.9    Compiling spki v0.6.0
168.9    Compiling env_logger v0.9.3
169.1    Compiling nu-ansi-term v0.46.0
169.2    Compiling clap v2.34.0
169.3    Compiling curve25519-dalek v4.0.0-rc.3
169.4    Compiling pin-project v1.1.3
169.5    Compiling resolv-conf v0.7.0
169.5    Compiling hyper v0.14.27
169.6 error: failed to run custom build command for `boring-sys v3.0.4 (https://github.com/Watfaq/boring.git?rev=24c006f#24c006fd)`
169.6
169.6 Caused by:
169.6   process didn't exit successfully: `/workdir/target/release/build/boring-sys-06b3d91f2747c55a/build-script-build` (exit status: 101)
169.6   --- stdout
169.6   cargo:rerun-if-env-changed=BORING_BSSL_PATH
169.6   cargo:rerun-if-env-changed=BORING_BSSL_INCLUDE_PATH
169.6   cargo:rerun-if-env-changed=BORING_BSSL_SOURCE_PATH
169.6   cargo:rerun-if-env-changed=BORING_SSL_PRECOMPILED_BCM_O
169.6   cargo:rerun-if-env-changed=BORINGSSL_BUILD_DIR
169.6   Initialized empty Git repository in /workdir/deps/boringssl/src/.git/
169.6
169.6   CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
169.6   CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
169.6   HOST_CMAKE_TOOLCHAIN_FILE = None
169.6   CMAKE_TOOLCHAIN_FILE = None
169.6   CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
169.6   CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
169.6   HOST_CMAKE_GENERATOR = None
169.6   CMAKE_GENERATOR = None
169.6   CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
169.6   CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
169.6   HOST_CMAKE_PREFIX_PATH = None
169.6   CMAKE_PREFIX_PATH = None
169.6   CMAKE_x86_64-unknown-linux-gnu = None
169.6   CMAKE_x86_64_unknown_linux_gnu = None
169.6   HOST_CMAKE = None
169.6   CMAKE = None
169.6   running: cd "/workdir/target/x86_64-unknown-linux-gnu/release/build/boring-sys-96644712df04612f/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/workdir/deps/boringssl/src" "-DCMAKE_INSTALL_PREFIX=/workdir/target/x86_64-unknown-linux-gnu/release/build/boring-sys-96644712df04612f/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=MinSizeRel"
169.6
169.6   --- stderr
169.6   hint: Using 'master' as the name for the initial branch. This default branch name
169.6   hint: is subject to change. To configure the initial branch name to use in all
169.6   hint: of your new repositories, which will suppress this warning, call:
169.6   hint:
169.6   hint:   git config --global init.defaultBranch <name>
169.6   hint:
169.6   hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
169.6   hint: 'development'. The just-created branch can be renamed via this command:
169.6   hint:
169.6   hint:   git branch -m <name>
169.6
169.6   thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:
169.6
169.6   failed to execute command: No such file or directory (os error 2)
169.6   is `cmake` not installed?
169.6
169.6   build script failed, must exit now
169.6   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
169.6 warning: build failed, waiting for other jobs to finish...
------
Dockerfile:5
--------------------
   4 |
   5 | >>> RUN chmod +x ./scripts/build.sh && \
   6 | >>>     sh ./scripts/build.sh x86_64-unknown-linux-gnu && \
   7 | >>>     cp ./target/artifacts/clash-x86_64-unknown-linux-gnu /usr/local/cargo/bin/clash-rs
   8 |
--------------------
ERROR: failed to solve: process "/bin/sh -c chmod +x ./scripts/build.sh &&     sh ./scripts/build.sh x86_64-unknown-linux-gnu &&     cp ./target/artifacts/clash-x86_64-unknown-linux-gnu /usr/local/cargo/bin/clash-rs" did not complete successfully: exit code: 101

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.

ibigbug commented 11 months ago

install cmake in your image

you'll probably need to install Go too

ibigbug commented 11 months ago

it can potentially be useful for https://github.com/Watfaq/clash-rs/issues/90

Nelocompne commented 11 months ago

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.

ibigbug commented 11 months ago
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

ibigbug commented 11 months ago

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

Nelocompne commented 11 months ago

Dockerfile is possible. there are just some problems with cross-compile, so I closed the issuse.