]> git.puffer.fish Git - matthieu/nova.git/commitdiff
add architectures and cross build
authorMatthieuCoder <matthieu@matthieu-dev.xyz>
Fri, 20 Jan 2023 12:18:03 +0000 (16:18 +0400)
committerMatthieuCoder <matthieu@matthieu-dev.xyz>
Fri, 20 Jan 2023 12:18:03 +0000 (16:18 +0400)
14 files changed:
.dockerignore
.gitignore
Cargo.lock
Cargo.toml
Dockerfile
docker-compose.yaml
exes/gateway/Cargo.toml
exes/gateway/src/main.rs
exes/ratelimit/Cargo.toml
exes/ratelimit/src/main.rs
exes/rest/Cargo.toml
exes/rest/src/main.rs
exes/webhook/Cargo.toml
exes/webhook/src/main.rs

index 27cfb9a3e0114bbbb5d8a6f208748ffd74a6b5c1..924efbbe19cb074bd1bdae05cd3c4f36017f5861 100644 (file)
@@ -1,2 +1,3 @@
 target/
-docs/
\ No newline at end of file
+docs/
+bin/
\ No newline at end of file
index bce375af00ca9b29bbfb45dd01a7a32dc880dcef..056ef9051fdf3a1713a6a3f1cc7b999bb2d068cf 100644 (file)
@@ -8,3 +8,4 @@ config.yml
 config/*\r
 build/\r
 *.yml\r
+bin/
\ No newline at end of file
index 05521869bf6f907eead561c084efe004d665a4fe..da521bdfc52a7408cdc6c9bc8c462eb57d0d6758 100644 (file)
@@ -776,12 +776,6 @@ dependencies = [
  "percent-encoding",
 ]
 
-[[package]]
-name = "fs_extra"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
-
 [[package]]
 name = "futures"
 version = "0.3.25"
@@ -885,7 +879,6 @@ dependencies = [
  "serde",
  "serde_json",
  "shared",
- "tikv-jemallocator",
  "tokio",
  "tokio-stream",
  "tracing",
@@ -1953,7 +1946,6 @@ dependencies = [
  "serde_json",
  "shared",
  "test-log",
- "tikv-jemallocator",
  "tokio",
  "tokio-stream",
  "tokio-test",
@@ -2074,7 +2066,6 @@ dependencies = [
  "serde",
  "serde_json",
  "shared",
- "tikv-jemallocator",
  "tokio",
  "tokio-stream",
  "tonic",
@@ -2569,27 +2560,6 @@ dependencies = [
  "once_cell",
 ]
 
-[[package]]
-name = "tikv-jemalloc-sys"
-version = "0.5.2+5.3.0-patched"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec45c14da997d0925c7835883e4d5c181f196fa142f8c19d7643d1e9af2592c3"
-dependencies = [
- "cc",
- "fs_extra",
- "libc",
-]
-
-[[package]]
-name = "tikv-jemallocator"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979"
-dependencies = [
- "libc",
- "tikv-jemalloc-sys",
-]
-
 [[package]]
 name = "time"
 version = "0.3.17"
@@ -3291,7 +3261,6 @@ dependencies = [
  "serde",
  "serde_json",
  "shared",
- "tikv-jemallocator",
  "tokio",
  "tracing",
  "twilight-model",
index cee8217c92946b19e661419fc7f1d6c424d1f7a7..2c746fab1a181fb0c3b7be4cb08d18b67e5feb83 100644 (file)
@@ -30,7 +30,6 @@ tracing-futures = "0.2"
 tracing-opentelemetry = "0.18"\r
 opentelemetry = { version = "0.18", features = ["rt-tokio"] }\r
 opentelemetry-http = "0.7"\r
-tikv-jemallocator = "0.5"\r
 \r
 criterion = { version = "0.4", features = ["async_tokio"] }\r
 tokio-test = "0.4.2"\r
index 3eba9a00f6abde1859318964ea2c9e4c7e8795fe..3a3c34c965ca6accd43fdf29a72cd3a69f92dbf4 100644 (file)
@@ -1,33 +1,27 @@
-FROM rust AS chef
-USER root
-COPY .cargo .cargo
-RUN cargo install cargo-chef
-RUN apt-get update && apt-get install -y protobuf-compiler
-WORKDIR /app
-
-# Planning install
-FROM chef AS planner
+# syntax=docker/dockerfile:1
+FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx
+FROM --platform=$BUILDPLATFORM rust:alpine as alpine_rbuild
+RUN apk add clang lld protobuf-dev build-base git
+# Copy the xx scripts
+COPY --from=xx / /
+# Copy source code
 COPY . .
-RUN cargo chef prepare --recipe-path recipe.json
-
-# Building all targets
-FROM chef AS builder
-COPY --from=planner /app/recipe.json recipe.json
 
-# Notice that we are specifying the --target flag!
-RUN cargo chef cook --release --recipe-path recipe.json
-COPY . .
-RUN cargo build --release 
+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
+ARG TARGETPLATFORM
+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 \
+    xx-cargo build --release --target-dir ./build
 
-# Base os
-FROM debian:latest AS runtime-base
-# RUN addgroup -S nova && adduser -S nova -G nova
-RUN apt-get update && apt-get install ca-certificates -y
+#Copy from the build/<target triple>/release folder to the out folder
+RUN mkdir ./out && cp ./build/*/release/* ./out || true
 
-# Final os
-FROM runtime-base AS runtime
+FROM alpine AS runtime
 ARG COMPONENT
 ENV COMPONENT=${COMPONENT}
-COPY --from=builder /app/target/release/${COMPONENT} /usr/local/bin/
-# USER nova
+COPY --from=alpine_rbuild /out/${COMPONENT} /usr/local/bin/
 ENTRYPOINT /usr/local/bin/${COMPONENT}
index 04ec54db137f5b03cd1d3aeabdd1cdecb38024a4..e222c2065d46a3708fdb616ff832ccfd541d1c51 100644 (file)
@@ -21,7 +21,9 @@ services:
       x-bake:
         platforms:
           - linux/amd64
-          - linux/arm64
+          - linux/arm64/v8
+          - linux/arm/v7
+          - linux/arm/v6
       args:
         - COMPONENT=cache
     volumes:
@@ -43,7 +45,9 @@ services:
       x-bake:
         platforms:
           - linux/amd64
-          - linux/arm64
+          - linux/arm64/v8
+          - linux/arm/v7
+          - linux/arm/v6
     volumes:
       - ./config/default.yml:/config/default.yml
     environment:
@@ -62,7 +66,9 @@ services:
       x-bake:
         platforms:
           - linux/amd64
-          - linux/arm64
+          - linux/arm64/v8
+          - linux/arm/v7
+          - linux/arm/v6
     volumes:
       - ./config/default.yml:/config/default.yml
     environment:
@@ -85,7 +91,9 @@ services:
       x-bake:
         platforms:
           - linux/amd64
-          - linux/arm64
+          - linux/arm64/v8
+          - linux/arm/v7
+          - linux/arm/v6
     volumes:
       - ./config/default.yml:/config/default.yml
     environment:
@@ -106,7 +114,9 @@ services:
       x-bake:
         platforms:
           - linux/amd64
-          - linux/arm64
+          - linux/arm64/v8
+          - linux/arm/v7
+          - linux/arm/v6
     volumes:
       - ./config/default.yml:/config/default.yml
     environment:
index 375a0201dbec68a206813df8536a511f58c3db19..39161381d8b7f0fbb3c0b987dbbd171ff0b7370e 100644 (file)
@@ -22,6 +22,3 @@ twilight-gateway = { version = "0.14" }
 twilight-model = "0.14"
 bytes = "1.3.0"
 async-nats = "0.26.0"
-
-[target.'cfg(not(target_os = "windows"))'.dependencies]
-tikv-jemallocator = { workspace = true }
\ No newline at end of file
index 900171c802be5f482c126c9570310f760fe160da..f1b029891f77ca4d838971c4692c0c72cfe3f778 100644 (file)
@@ -1,11 +1,4 @@
 use gateway::GatewayServer;
 use leash::ignite;
 
-#[cfg(not(target_os = "windows"))]
-use tikv_jemallocator::Jemalloc;
-
-#[cfg(not(target_os = "windows"))]
-#[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
-
 ignite!(GatewayServer);
index d7dc554f01e4b52898a2b0a31d1351d69df69c41..5be1a3412224f9ef8ce17ddf9e7eba1cf15d9e5f 100644 (file)
@@ -33,9 +33,6 @@ tracing-subscriber = { workspace = true }
 test-log = { workspace = true }
 env_logger = { workspace = true }
 
-[target.'cfg(not(target_os = "windows"))'.dependencies]
-tikv-jemallocator = { workspace = true }
-
 [[bench]]
 name = "bucket"
 harness = false
index b7643679ecd0dc50c6ce70f3dc16951147a51c71..2de812b531d439e6050b3b483277db0f42267f3c 100644 (file)
@@ -1,11 +1,4 @@
 use leash::ignite;
 use ratelimit::RatelimiterServerComponent;
 
-#[cfg(not(target_os = "windows"))]
-use tikv_jemallocator::Jemalloc;
-
-#[cfg(not(target_os = "windows"))]
-#[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
-
 ignite!(RatelimiterServerComponent);
index d37da95b96eb45e1d6190caac1a727b060197152..aed205faf78eb96469944a219853a9c2720a4b4e 100644 (file)
@@ -30,6 +30,3 @@ hashring = "0.3.0"
 tonic = "0.8.3"
 tokio-stream = "0.1.11"
 dns-lookup = "1.0.8"
-
-[target.'cfg(not(target_os = "windows"))'.dependencies]
-tikv-jemallocator = { workspace = true }
\ No newline at end of file
index 1e73e09867586a6e09df7e726633adbfa8fc8a38..fe8ada759ab1ec131bd00d7f134ab2aed31d7770 100644 (file)
@@ -1,11 +1,4 @@
 use leash::ignite;
 use rest::ReverseProxyServer;
 
-#[cfg(not(target_os = "windows"))]
-use tikv_jemallocator::Jemalloc;
-
-#[cfg(not(target_os = "windows"))]
-#[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
-
 ignite!(ReverseProxyServer);
index 7b4a185ad066eabc54828da6882db97be1cc7777..0078a70e622f4193a59ad98fcee4632aec14c382 100644 (file)
@@ -19,6 +19,3 @@ ed25519-dalek = "1"
 twilight-model = { version = "0.14" }
 
 async-nats = "0.26.0"
-
-[target.'cfg(not(target_os = "windows"))'.dependencies]
-tikv-jemallocator = "0.5"
\ No newline at end of file
index bbacda7b8ccf85f175e0a99320d83e7ceea3e23a..f53172558ca50d64363e1f3cbe1a0f1315e34c06 100644 (file)
@@ -1,11 +1,4 @@
 use leash::ignite;
 use webhook::WebhookServer;
 
-#[cfg(not(target_os = "windows"))]
-use tikv_jemallocator::Jemalloc;
-
-#[cfg(not(target_os = "windows"))]
-#[global_allocator]
-static GLOBAL: Jemalloc = Jemalloc;
-
 ignite!(WebhookServer);