Skip to content

Commit aaa9cc4

Browse files
refactor: remove cargo sonic
1 parent 820b9a6 commit aaa9cc4

4 files changed

Lines changed: 9 additions & 118 deletions

File tree

debian.Dockerfile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,23 @@
55
FROM rust:1.96.0-slim-trixie AS builder
66

77
WORKDIR /app/nittei
8-
ARG TARGETARCH
98
ENV BUILD_PROFILE=release
10-
# cargo-sonic intentionally does not reuse payload RUSTFLAGS / CARGO_*_RUSTFLAGS
11-
# for its small generated loader build. Tell it to use mold for the loader too,
12-
# matching the payload link step configured in .cargo/config.toml.
13-
ENV CARGO_SONIC_LOADER_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
149

1510
RUN apt update \
1611
&& apt install -y --no-install-recommends curl openssl ca-certificates pkg-config build-essential libssl-dev mold \
1712
&& apt clean \
1813
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1914

20-
RUN cargo install cargo-sonic --version 0.2.0 --locked
21-
2215
COPY .cargo .cargo
2316
COPY ./Cargo.toml ./Cargo.lock ./
2417
COPY ./clients/rust ./clients/rust
2518
COPY ./crates ./crates
2619
COPY ./bins ./bins
27-
COPY ./scripts ./scripts
2820

29-
RUN ./scripts/build_release.sh
21+
RUN mkdir -p /tmp/nittei-build \
22+
&& cargo build --locked --profile ${BUILD_PROFILE} --bin nittei --bin nittei-migrate \
23+
&& cp ./target/${BUILD_PROFILE}/nittei /tmp/nittei-build/nittei \
24+
&& cp ./target/${BUILD_PROFILE}/nittei-migrate /tmp/nittei-build/nittei-migrate
3025

3126
# Use the distroless base image for final image
3227
FROM gcr.io/distroless/cc-debian13

debianWithDD.Dockerfile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,24 @@ WORKDIR /app/nittei
1010

1111
ARG TARGETARCH
1212
ENV BUILD_PROFILE=release-dd
13+
# RUSTFLAGS overrides .cargo/config.toml rustflags, so mold must be set explicitly here.
1314
ENV RUSTFLAGS="-C force-frame-pointers=yes -C link-arg=-fuse-ld=mold"
14-
# cargo-sonic intentionally does not reuse payload RUSTFLAGS / CARGO_*_RUSTFLAGS
15-
# for its small generated loader build. Tell it to use mold for the loader too,
16-
# matching the payload link step. Frame pointers are not needed on the launcher
17-
# (ddprof profiles the payload process, not the loader).
18-
ENV CARGO_SONIC_LOADER_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
1915

2016
RUN apt update \
2117
&& apt install -y --no-install-recommends curl openssl ca-certificates pkg-config build-essential libssl-dev mold \
2218
&& apt clean \
2319
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2420

25-
RUN cargo install cargo-sonic --version 0.2.0 --locked
26-
2721
COPY .cargo .cargo
2822
COPY ./Cargo.toml ./Cargo.lock ./
2923
COPY ./clients/rust ./clients/rust
3024
COPY ./crates ./crates
3125
COPY ./bins ./bins
32-
COPY ./scripts ./scripts
3326

34-
RUN ./scripts/build_release.sh
27+
RUN mkdir -p /tmp/nittei-build \
28+
&& cargo build --locked --profile ${BUILD_PROFILE} --bin nittei --bin nittei-migrate \
29+
&& cp ./target/${BUILD_PROFILE}/nittei /tmp/nittei-build/nittei \
30+
&& cp ./target/${BUILD_PROFILE}/nittei-migrate /tmp/nittei-build/nittei-migrate
3531

3632
# Install ddprof
3733
RUN ARCH_IN_URL=$(case "${TARGETARCH:-$(uname -m)}" in \

docs/deployment.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ cargo run --release
1212

1313
The production Docker builds install [`mold`](https://github.com/rui314/mold) and configure Rust to use it as the linker. This keeps release and profiling builds faster, especially when LTO is enabled.
1414

15-
### cargo-sonic
16-
17-
The Debian Docker images use [`cargo-sonic`](https://docs.rs/crate/cargo-sonic/latest) to build CPU-dispatched binaries. The image contains a baseline payload plus an optimized payload for the target architecture: `x86-64-v3` on `amd64`, and `neoverse-n1` on `arm64`.
18-
19-
The build uses `--loader=bundle`, so the final image must include both the launcher binaries and their adjacent `.bundle` directories.
20-
2115
### Database
2216

2317
Then set up a postgres db with the init script specified [here](../crates/infra/migrations/dbinit.sql).

scripts/build_release.sh

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)