11# syntax=docker/dockerfile:1
2- FROM scratch AS pkg
2+ FROM scratch AS router_pkg
3+ FROM scratch AS sdk_rs_pkg
34FROM scratch AS config
45
56FROM rust:1.90-slim-bookworm AS build
@@ -12,21 +13,34 @@ RUN update-ca-certificates
1213RUN rustup component add rustfmt
1314
1415WORKDIR /usr/src
15- # Create blank project
16+ # Create blank projects
1617RUN USER=root cargo new router
18+ RUN USER=root cargo new sdk-rs
1719
1820# Copy Cargo files
19- COPY --from=pkg Cargo.toml /usr/src/router/
21+ COPY --from=router_pkg Cargo.toml /usr/src/router/
22+ COPY --from=sdk_rs_pkg Cargo.toml /usr/src/sdk-rs/
2023COPY --from=config Cargo.lock /usr/src/router/
2124
25+ WORKDIR /usr/src/sdk-rs
26+ # Get the dependencies cached, so we can use dummy input files so Cargo wont fail
27+ RUN echo 'fn main() { println!(""); }' > ./src/main.rs
28+ RUN echo 'fn main() { println!(""); }' > ./src/lib.rs
29+ RUN cargo build --release
30+
31+ # Copy in the actual source code
32+ COPY --from=sdk_rs_pkg src ./src
33+ RUN touch ./src/main.rs
34+ RUN touch ./src/lib.rs
35+
2236WORKDIR /usr/src/router
2337# Get the dependencies cached, so we can use dummy input files so Cargo wont fail
2438RUN echo 'fn main() { println!(""); }' > ./src/main.rs
2539RUN echo 'fn main() { println!(""); }' > ./src/lib.rs
2640RUN cargo build --release
2741
2842# Copy in the actual source code
29- COPY --from=pkg src ./src
43+ COPY --from=router_pkg src ./src
3044RUN touch ./src/main.rs
3145RUN touch ./src/lib.rs
3246
@@ -53,7 +67,7 @@ RUN mkdir /dist/schema
5367
5468# Copy in the required files from our build image
5569COPY --from=build --chown=root:root /usr/src/router/target/release/router /dist
56- COPY --from=pkg router.yaml /dist/config/router.yaml
70+ COPY --from=router_pkg router.yaml /dist/config/router.yaml
5771
5872WORKDIR /dist
5973
0 commit comments