diff --git a/.github/workflows/kuksa_databroker-cli_build.yml b/.github/workflows/kuksa_databroker-cli_build.yml index 55abca51f..c95ed2ade 100644 --- a/.github/workflows/kuksa_databroker-cli_build.yml +++ b/.github/workflows/kuksa_databroker-cli_build.yml @@ -32,6 +32,8 @@ jobs: runs-on: ubuntu-latest steps: + - name: Install Protoc + run: sudo apt-get install -y protobuf-compiler - uses: actions/checkout@v3 - name: cargo fmt working-directory: ${{github.workspace}} diff --git a/.github/workflows/kuksa_databroker_build.yml b/.github/workflows/kuksa_databroker_build.yml index fe32f67e7..a2162fd48 100644 --- a/.github/workflows/kuksa_databroker_build.yml +++ b/.github/workflows/kuksa_databroker_build.yml @@ -32,6 +32,8 @@ jobs: runs-on: ubuntu-latest steps: + - name: Install Protoc + run: sudo apt-get install -y protobuf-compiler - uses: actions/checkout@v3 - name: cargo fmt working-directory: ${{github.workspace}} @@ -45,6 +47,8 @@ jobs: runs-on: ubuntu-latest steps: + - name: Install Protoc + run: sudo apt-get install -y protobuf-compiler - uses: actions/checkout@v3 - uses: actions-rs/install@v0.1 with: diff --git a/Cargo.lock b/Cargo.lock index 5ca1f5cbf..67ba47a21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.63" +version = "0.1.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff18d764974428cf3a9328e23fc5c986f5fbed46e6cd4cdf42544df5d297ec1" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", @@ -76,6 +76,52 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fb79c228270dcf2426e74864cabc94babb5dbab01a4314e702d2f16540e1591" +dependencies = [ + "async-trait", + "axum-core", + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-http", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2f958c80c248b34b9a877a643811be8dbca03ca5ba827f2b63baf3a81e5fc4e" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "base64" version = "0.13.1" @@ -146,7 +192,7 @@ version = "3.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" dependencies = [ - "heck 0.4.0", + "heck", "proc-macro-error", "proc-macro2", "quote", @@ -295,11 +341,32 @@ dependencies = [ "syn", ] +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -419,9 +486,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -432,7 +499,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.4", + "tokio-util", "tracing", ] @@ -442,15 +509,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.4.0" @@ -466,6 +524,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "http" version = "0.2.8" @@ -488,6 +552,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + [[package]] name = "httparse" version = "1.8.0" @@ -502,9 +572,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" dependencies = [ "bytes", "futures-channel", @@ -565,6 +635,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76e86b86ae312accbf05ade23ce76b625e0e47a255712b7414037385a1c05380" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -680,6 +761,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "log" version = "0.4.17" @@ -698,6 +785,12 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "matchit" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" + [[package]] name = "memchr" version = "2.5.0" @@ -713,6 +806,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + [[package]] name = "mio" version = "0.8.5" @@ -722,7 +821,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -816,7 +915,7 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -855,9 +954,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "petgraph" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", "indexmap", @@ -945,6 +1044,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -980,9 +1089,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.9.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" dependencies = [ "bytes", "prost-derive", @@ -990,29 +1099,31 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.9.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" +checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" dependencies = [ "bytes", - "heck 0.3.3", + "heck", "itertools", "lazy_static", "log", "multimap", "petgraph", + "prettyplease", "prost", "prost-types", "regex", + "syn", "tempfile", "which", ] [[package]] name = "prost-derive" -version = "0.9.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" +checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" dependencies = [ "anyhow", "itertools", @@ -1023,11 +1134,10 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.9.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a" +checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" dependencies = [ - "bytes", "prost", ] @@ -1133,15 +1243,6 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "ring" version = "0.16.20" @@ -1169,6 +1270,20 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "rustix" +version = "0.36.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + [[package]] name = "rustversion" version = "1.0.11" @@ -1250,9 +1365,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -1308,18 +1423,23 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall 0.2.16", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys 0.42.0", ] [[package]] @@ -1428,7 +1548,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.42.0", ] [[package]] @@ -1461,21 +1581,7 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", - "tokio-util 0.7.4", -] - -[[package]] -name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", + "tokio-util", ] [[package]] @@ -1494,12 +1600,13 @@ dependencies = [ [[package]] name = "tonic" -version = "0.6.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a" +checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" dependencies = [ "async-stream", "async-trait", + "axum", "base64", "bytes", "futures-core", @@ -1515,7 +1622,7 @@ dependencies = [ "prost-derive", "tokio", "tokio-stream", - "tokio-util 0.6.10", + "tokio-util", "tower", "tower-layer", "tower-service", @@ -1525,10 +1632,11 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.6.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757" +checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" dependencies = [ + "prettyplease", "proc-macro2", "prost-build", "quote", @@ -1549,12 +1657,31 @@ dependencies = [ "rand", "slab", "tokio", - "tokio-util 0.7.4", + "tokio-util", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tower-http" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.2" @@ -1653,12 +1780,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" - [[package]] name = "unicode-width" version = "0.1.10" @@ -1844,6 +1965,30 @@ dependencies = [ "windows_x86_64_msvc", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.1" diff --git a/Cargo.toml b/Cargo.toml index f64967465..38413ad14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ #******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation +# Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -20,10 +20,25 @@ members = [ "kuksa_databroker/databroker-examples", ] +[workspace.dependencies] +clap = { version = "3.1.10", default-features = false } +databroker-proto = { path = "kuksa_databroker/databroker-proto" } +# prost has no features +prost = "0.11" +# prost-types has no features +prost-types = "0.11" +# tokio does not enable features by default +tokio = "1.17.0" +# tokio-stream has no features +tokio-stream = "0.1.8" +tonic = { version = "0.8", default-features = false } +tonic-build = { version = "0.8", default-features = false } + [profile.release] lto = true # Link time optimization (dead code removal etc...) opt-level = "s" codegen-units = 1 incremental = false +strip = true # debug = true # for profiling (turn off otherwise) # split-debuginfo = "packed" # only enable when `debug = true`` diff --git a/kuksa_databroker/Dockerfile b/kuksa_databroker/Dockerfile index bd3fc0651..d0d176ab2 100644 --- a/kuksa_databroker/Dockerfile +++ b/kuksa_databroker/Dockerfile @@ -1,5 +1,5 @@ # /******************************************************************************** -# * Copyright (c) 2022 Contributors to the Eclipse Foundation +# * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation # * # * See the NOTICE file(s) distributed with this work for additional # * information regarding copyright ownership. @@ -15,44 +15,27 @@ # This builds KUKSA databroker -FROM rust:1.65-alpine as base -RUN apk add git musl-dev python3 protoc ncurses-terminfo-base make -RUN rustup component add rustfmt +FROM ghcr.io/rust-cross/rust-musl-cross:x86_64-musl AS builder-amd64 +ENV BUILDTARGET="x86_64-unknown-linux-musl" -FROM base AS builder-amd64 -RUN echo "AMD64 quirks" -# it seems on AMD build some dependency requires zlib headers -# also the grpc proto compilation always falls back to -# some binaries downloaded by cargo that require glibc -RUN apk add libc6-compat libstdc++ gcompat -ENV BUILDTARGET=x86_64-unknown-linux-musl - - -FROM base AS builder-arm64 -RUN echo "ARM64 quirks" -# Need flag for MUSL arm builds, to prevent linker error -# on missing __getauxval symbol, see also -# https://github.com/rust-lang/rust/issues/89626 -ENV CFLAGS=-mno-outline-atomics -ENV BUILDTARGET=aarch64-unknown-linux-musl - +FROM ghcr.io/rust-cross/rust-musl-cross:aarch64-musl AS builder-arm64 +ENV BUILDTARGET="aarch64-unknown-linux-musl" FROM builder-$TARGETARCH as builder ARG TARGETARCH + +RUN apt-get update && apt-get install -y protobuf-compiler \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + # This will speed up fetching the crate.io index in the future, see # https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html ENV CARGO_UNSTABLE_SPARSE_REGISTRY=true RUN echo "Building for $TARGETARCH" +ENV SRC="/home/rust/src" +WORKDIR ${SRC} -RUN mkdir /build -WORKDIR /build - -# See also https://github.com/rust-lang/cargo/issues/10583, -# without this needs more than 12GB in runner if somebody wants to buildx -# it with the common qemu setup -RUN ln -s /usr/bin/git /usr/local/cargo/bin/ ENV CARGO_NET_GIT_FETCH_WITH_CLI=true RUN cargo install cargo-license @@ -64,21 +47,19 @@ RUN cargo install cargo-license COPY . . # Creating BOM -WORKDIR /build/kuksa_databroker/createbom +WORKDIR ${SRC}/kuksa_databroker/createbom RUN rm -rf ../thirdparty RUN python3 createbom.py ../databroker -WORKDIR /build/kuksa_databroker/databroker - -ENV RUSTFLAGS='-C link-arg=-s' +WORKDIR ${SRC}/kuksa_databroker/databroker -RUN cargo build --bin databroker --release --target $BUILDTARGET -RUN mv /build/target/$BUILDTARGET/release/databroker /build/ +RUN cargo build --bin databroker --release --target $BUILDTARGET +RUN mv ${SRC}/target/$BUILDTARGET/release/databroker ${SRC}/ -FROM scratch +FROM scratch -COPY --from=builder /build/databroker /app/databroker -COPY --from=builder /build/kuksa_databroker/databroker/thirdparty /app/thirdparty +COPY --from=builder /home/rust/src/databroker /app/databroker +COPY --from=builder /home/rust/src/kuksa_databroker/databroker/thirdparty /app/thirdparty ADD ./data/vss-core/vss_release_3.1.1.json vss_release_3.1.1.json diff --git a/kuksa_databroker/Dockerfile-cli b/kuksa_databroker/Dockerfile-cli index 95c3ec7a6..3017b797a 100644 --- a/kuksa_databroker/Dockerfile-cli +++ b/kuksa_databroker/Dockerfile-cli @@ -1,5 +1,5 @@ # /******************************************************************************** -# * Copyright (c) 2022 Contributors to the Eclipse Foundation +# * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation # * # * See the NOTICE file(s) distributed with this work for additional # * information regarding copyright ownership. @@ -15,46 +15,48 @@ # This builds the databroker-cli -FROM rust:1.65-alpine as builder +FROM ghcr.io/rust-cross/rust-musl-cross:x86_64-musl AS builder-amd64 +ENV BUILDTARGET="x86_64-unknown-linux-musl" + + +FROM ghcr.io/rust-cross/rust-musl-cross:aarch64-musl AS builder-arm64 +ENV BUILDTARGET="aarch64-unknown-linux-musl" + +FROM builder-$TARGETARCH as builder +ARG TARGETARCH + +RUN apt-get update && apt-get install -y protobuf-compiler \ + && apt-get clean && rm -rf /var/lib/apt/lists/* # This will speed up fetching the crate.io index in the future, see # https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html ENV CARGO_UNSTABLE_SPARSE_REGISTRY=true -RUN rustup component add rustfmt +RUN echo "Building for $TARGETARCH" +ENV SRC="/home/rust/src" +WORKDIR ${SRC} -RUN mkdir /build -WORKDIR /build +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true ADD kuksa_databroker kuksa_databroker ADD proto proto ADD Cargo.toml Cargo.toml -RUN apk add git musl-dev python3 protoc ncurses-terminfo-base -# See also https://github.com/rust-lang/cargo/issues/10583, -# without this needs more than 12GB in runner if somebody wants to buildx -# it with the common qemu setup -RUN ln -s /usr/bin/git /usr/local/cargo/bin/ -#RUN ls /usr/local/cargo/bin/ -ENV CARGO_NET_GIT_FETCH_WITH_CLI=true - # Creating BOM RUN cargo install cargo-license -WORKDIR /build/kuksa_databroker/createbom +WORKDIR ${SRC}/kuksa_databroker/createbom RUN rm -rf ../thirdparty RUN python3 createbom.py ../databroker-cli -WORKDIR /build/kuksa_databroker/databroker-cli - -ENV RUSTFLAGS='-C link-arg=-s' -RUN cargo build --bin databroker-cli --release - +WORKDIR ${SRC}/kuksa_databroker/databroker-cli +RUN cargo build --bin databroker-cli --release --target $BUILDTARGET +RUN mv ${SRC}/target/$BUILDTARGET/release/databroker-cli ${SRC}/ FROM scratch -COPY --from=builder /build//target/release/databroker-cli /app/databroker-cli -COPY --from=builder /build/kuksa_databroker/databroker-cli/thirdparty /app/thirdparty -COPY --from=builder /etc/terminfo /etc/terminfo +COPY --from=builder /home/rust/src/databroker-cli /app/databroker-cli +COPY --from=builder /home/rust/src/kuksa_databroker/databroker-cli/thirdparty /app/thirdparty +COPY --from=builder /lib/terminfo /etc/terminfo ENTRYPOINT [ "/app/databroker-cli" ] diff --git a/kuksa_databroker/databroker-cli/Cargo.toml b/kuksa_databroker/databroker-cli/Cargo.toml index 1a4c8db1f..7b59efc6d 100644 --- a/kuksa_databroker/databroker-cli/Cargo.toml +++ b/kuksa_databroker/databroker-cli/Cargo.toml @@ -1,5 +1,5 @@ #******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation +# Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -19,20 +19,20 @@ edition = "2018" license = "Apache-2.0" [dependencies] -databroker-proto = { path = "../databroker-proto" } -tonic = "0.6.2" -prost = "0.9.0" -prost-types = "0.9.0" -tokio = { version = "1.17.0", features = [ +databroker-proto = { workspace = true } +tonic = { workspace = true, features = ["transport", "channel", "prost"] } +prost = { workspace = true } +prost-types = { workspace = true } +tokio = { workspace = true, features = [ "macros", "rt-multi-thread", "time", "signal", ] } -tokio-stream = { version = "0.1.8", features = ["sync"] } +tokio-stream = { workspace = true, features = ["sync"] } linefeed = "0.6" ansi_term = "0.12" -clap = { version = "3.1.10", default-features = false, features = [ +clap = { workspace = true, features = [ "std", "env", "derive", diff --git a/kuksa_databroker/databroker-cli/src/client.rs b/kuksa_databroker/databroker-cli/src/client.rs index 4d2b5685a..064543b09 100644 --- a/kuksa_databroker/databroker-cli/src/client.rs +++ b/kuksa_databroker/databroker-cli/src/client.rs @@ -11,7 +11,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -use std::collections::HashMap; +use std::{collections::HashMap, convert::TryFrom}; use databroker_proto::sdv::databroker as proto; use http::Uri; @@ -72,7 +72,7 @@ impl Client { } pub fn set_access_token(&mut self, token: impl AsRef) -> Result<(), TokenError> { - match tonic::metadata::AsciiMetadataValue::from_str(&format!("Bearer {}", token.as_ref())) { + match tonic::metadata::AsciiMetadataValue::try_from(&format!("Bearer {}", token.as_ref())) { Ok(token) => { self.token = Some(token); Ok(()) diff --git a/kuksa_databroker/databroker-examples/Cargo.toml b/kuksa_databroker/databroker-examples/Cargo.toml index a4b1b85af..4ce619d66 100644 --- a/kuksa_databroker/databroker-examples/Cargo.toml +++ b/kuksa_databroker/databroker-examples/Cargo.toml @@ -1,5 +1,5 @@ #******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation +# Copyright (c) 2023 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -19,14 +19,14 @@ edition = "2018" license = "Apache-2.0" [dependencies] -databroker-proto = { path = "../databroker-proto" } -tonic = "0.6.2" -prost = "0.9.0" -prost-types = "0.9.0" -tokio = { version = "1.17.0", features = [ +databroker-proto = { workspace = true } +tonic = { workspace = true } +prost = { workspace = true } +prost-types = { workspace = true } +tokio = { workspace = true, features = [ "macros", "rt-multi-thread", "time", "signal", ] } -tokio-stream = { version = "0.1.8", features = ["sync"] } +tokio-stream = { workspace = true, features = ["sync"] } diff --git a/kuksa_databroker/databroker-proto/Cargo.toml b/kuksa_databroker/databroker-proto/Cargo.toml index fd4b26287..88d40008b 100644 --- a/kuksa_databroker/databroker-proto/Cargo.toml +++ b/kuksa_databroker/databroker-proto/Cargo.toml @@ -19,9 +19,9 @@ edition = "2018" license = "Apache-2.0" [dependencies] -tonic = "0.6.2" -prost = "0.9.0" -prost-types = "0.9.0" +tonic = { workspace = true, features = ["transport", "channel", "codegen", "prost"] } +prost = { workspace = true } +prost-types = { workspace = true } [build-dependencies] -tonic-build = "0.6.2" +tonic-build = { workspace = true, features = ["transport", "prost"] } diff --git a/kuksa_databroker/databroker-proto/build.rs b/kuksa_databroker/databroker-proto/build.rs index e1dbfe764..d3a70acc9 100644 --- a/kuksa_databroker/databroker-proto/build.rs +++ b/kuksa_databroker/databroker-proto/build.rs @@ -1,5 +1,5 @@ /******************************************************************************** -* Copyright (c) 2022 Contributors to the Eclipse Foundation +* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -12,15 +12,9 @@ ********************************************************************************/ fn main() -> Result<(), Box> { - // Only format generated code if rustfmt is available - let rustfmt_available = std::process::Command::new("rustfmt") - .arg("--version") - .status() - .is_ok(); - tonic_build::configure() .compile_well_known_types(false) - .format(rustfmt_available) + .protoc_arg("--experimental_allow_proto3_optional") .compile( &[ "proto/sdv/databroker/v1/broker.proto", diff --git a/kuksa_databroker/databroker/Cargo.toml b/kuksa_databroker/databroker/Cargo.toml index 95e414ce2..72537b7c1 100644 --- a/kuksa_databroker/databroker/Cargo.toml +++ b/kuksa_databroker/databroker/Cargo.toml @@ -1,5 +1,5 @@ #******************************************************************************** -# Copyright (c) 2022 Contributors to the Eclipse Foundation +# Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation # # See the NOTICE file(s) distributed with this work for additional # information regarding copyright ownership. @@ -23,24 +23,24 @@ name = "databroker" path = "src/lib.rs" [dependencies] -databroker-proto = { path = "../databroker-proto" } -tonic = "0.6.2" -prost = "0.9.0" -prost-types = "0.9.0" -tokio = { version = "1.17.0", features = [ +databroker-proto = { workspace = true } +tonic = { workspace = true, features = ["transport", "channel", "prost"] } +prost = { workspace = true } +prost-types = { workspace = true } +tokio = { workspace = true, features = [ "macros", "rt-multi-thread", "time", "signal", ] } -tokio-stream = { version = "0.1.8", features = ["sync", "net"] } +tokio-stream = { workspace = true, features = ["sync", "net"] } tracing = "0.1.34" tracing-subscriber = { version = "0.3.11", default-features = false, features = [ "fmt", "env-filter", "ansi", ] } -clap = { version = "3.1.10", default-features = false, features = [ +clap = { workspace = true, features = [ "std", "env", ] } diff --git a/kuksa_databroker/databroker/build.rs b/kuksa_databroker/databroker/build.rs index 189497f7a..bc2cfebfa 100644 --- a/kuksa_databroker/databroker/build.rs +++ b/kuksa_databroker/databroker/build.rs @@ -7,12 +7,16 @@ fn main() -> Result<()> { // Cargo let cargo = config.cargo_mut(); - + *cargo.features_mut() = false; // Enable VERGEN_CARGO_PROFILE *cargo.profile_mut() = true; + *cargo.target_triple_mut() = false; // Git let git = config.git_mut(); + *git.commit_author_mut() = false; + *git.commit_count_mut() = false; + *git.commit_message_mut() = false; // Rerun on HEAD change *git.rerun_on_head_change_mut() = true;