Skip to content

Commit 2b1945c

Browse files
authored
chore(build): add debug symbols to release profile (#409)
1 parent 5e2255c commit 2b1945c

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,5 @@ inherits = "dev"
148148
debug-assertions = false
149149

150150
[profile.release]
151-
lto = true
151+
debug = "line-tables-only"
152+
lto = true

Dockerfile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
# syntax=docker/dockerfile:1.4
2+
23
FROM rust:1.79.0-bookworm as builder
4+
35
ARG TARGETPLATFORM
46
ARG GIT_V_VERSION
57
ARG ONNXRUNTIME_VERSION=1.17.0
68
ARG PROFILE=release
79
ARG FEATURES
810

9-
RUN apt-get update && apt-get install -y llvm-dev libclang-dev clang cmake
11+
RUN apt-get update && apt-get install -y llvm-dev libclang-dev clang cmake binutils
12+
1013
WORKDIR /usr/src/edge-runtime
1114

12-
RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} \
13-
cargo install cargo-strip
1415
COPY . .
1516

1617
RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} --mount=type=cache,target=/usr/src/edge-runtime/target,id=${TARGETPLATFORM} \
1718
GIT_V_TAG=${GIT_V_VERSION} cargo build --profile ${PROFILE} --features "${FEATURES}" && \
18-
cargo strip && \
1919
mv /usr/src/edge-runtime/target/${PROFILE}/edge-runtime /root
2020

21+
RUN objcopy --compress-debug-sections \
22+
--only-keep-debug \
23+
/root/edge-runtime \
24+
/root/edge-runtime.debug
25+
RUN objcopy --strip-debug \
26+
--add-gnu-debuglink=/root/edge-runtime.debug \
27+
/root/edge-runtime
28+
2129
RUN ./scripts/install_onnx.sh $ONNXRUNTIME_VERSION $TARGETPLATFORM /root/libonnxruntime.so
2230
RUN ./scripts/download_models.sh
2331

24-
2532
FROM debian:bookworm-slim
33+
2634
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
2735
RUN apt-get remove -y perl && apt-get autoremove -y
36+
2837
COPY --from=builder /root/edge-runtime /usr/local/bin/edge-runtime
38+
COPY --from=builder /root/edge-runtime.debug /usr/local/bin/edge-runtime.debug
2939
COPY --from=builder /root/libonnxruntime.so /usr/local/bin/libonnxruntime.so
3040
COPY --from=builder /usr/src/edge-runtime/models /etc/sb_ai/models
41+
3142
ENV ORT_DYLIB_PATH=/usr/local/bin/libonnxruntime.so
3243
ENV SB_AI_MODELS_DIR=/etc/sb_ai/models
44+
3345
ENTRYPOINT ["edge-runtime"]

0 commit comments

Comments
 (0)