File tree 1 file changed +20
-6
lines changed
1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change 1
1
# build openapi-codegen
2
- FROM rust:1.85 AS openapi-codegen-builder
3
- ARG RUST_TARGET="x86_64-unknown-linux-musl"
2
+ FROM docker.io/lukemathwalker/cargo-chef:latest-rust-1.85 AS chef
4
3
WORKDIR /app
5
- RUN rustup target add ${RUST_TARGET}
4
+
5
+ FROM chef AS planner
6
+
7
+ COPY Cargo.toml .
8
+ COPY Cargo.lock .
9
+ COPY build.rs .
10
+ COPY src /app/src
11
+
12
+ RUN cargo chef prepare --recipe-path recipe.json
13
+
14
+ FROM chef AS openapi-codegen-builder
15
+
16
+ COPY --from=planner /app/recipe.json recipe.json
17
+
18
+ RUN cargo chef cook --release --recipe-path recipe.json
19
+
6
20
COPY Cargo.toml .
7
21
COPY Cargo.lock .
8
22
COPY build.rs .
9
23
COPY src /app/src
10
- RUN cargo build --target ${RUST_TARGET} --release --bin openapi-codegen
24
+
25
+ RUN cargo build --release --bin openapi-codegen
11
26
12
27
# build rubyfmt
13
28
FROM docker.io/rust:1.85 AS rubyfmt-builder
@@ -50,7 +65,6 @@ RUN rm -rf /usr/local/go/*.md && \
50
65
51
66
# main image
52
67
FROM alpine:3.21
53
- ARG RUST_TARGET="x86_64-unknown-linux-musl"
54
68
ENV PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/root/.cargo/bin"
55
69
RUN apk add --no-cache openjdk17-jre-headless curl gcompat libgcc ruff libstdc++
56
70
@@ -116,4 +130,4 @@ RUN apk add --no-cache binutils && \
116
130
apk del binutils
117
131
118
132
# openapi-codegen
119
- COPY --from=openapi-codegen-builder /app/target/${RUST_TARGET}/ release/openapi-codegen /usr/bin/
133
+ COPY --from=openapi-codegen-builder /app/target/release/openapi-codegen /usr/bin/
You can’t perform that action at this time.
0 commit comments