Skip to content

Commit e57159a

Browse files
authored
Fixes multiplatform builds (#6)
Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent 3db0673 commit e57159a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

.github/workflows/commit.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ jobs:
112112
platform:
113113
- os: ubuntu-22.04
114114
arch: amd64
115-
# TODO: fix
116-
# - os: ubuntu-22.04-arm
117-
# arch: arm64
115+
- os: ubuntu-22.04-arm
116+
arch: arm64
118117

119118
steps:
120119
- name: Checkout

Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
FROM --platform=$BUILDPLATFORM rust:1.84 AS rust_builder
2-
3-
# We need libclang to do the bindgen.
4-
RUN apt update && apt install -y clang
1+
FROM --platform=$BUILDPLATFORM rust:1.84 AS rust_fetcher
52

63
WORKDIR /app
74

8-
# Cache dependencies by copying only the Cargo files and fetching them.
5+
# Cache dependencies by copying only the Cargo files and fetching them on the build platform.
96
COPY ./rust/Cargo.toml ./rust/Cargo.lock ./
107
RUN mkdir src && echo "" > src/lib.rs
118
RUN cargo fetch
129
RUN rm -rf src
1310

11+
FROM rust:1.84 AS rust_builder
12+
13+
# We need libclang to do the bindgen.
14+
RUN apt update && apt install -y clang
15+
16+
# Copy the dependencies from the previous stage.
17+
WORKDIR /app
18+
COPY --from=rust_fetcher /usr/local/cargo/git /usr/local/cargo/git
19+
COPY --from=rust_fetcher /usr/local/cargo/registry /usr/local/cargo/registry
20+
1421
# Then, copy the entire source code and build.
1522
COPY ./rust .
1623
RUN cargo build
1724

1825
# Finally, copy the built library to the final image.
19-
FROM --platform=$BUILDPLATFORM envoyproxy/envoy-dev:80c1ac2143a7a73932c9dff814d38fd6867fe691 AS envoy
26+
FROM envoyproxy/envoy-dev:80c1ac2143a7a73932c9dff814d38fd6867fe691 AS envoy
2027
ENV ENVOY_DYNAMIC_MODULES_SEARCH_PATH=/usr/local/lib
2128
COPY --from=rust_builder /app/target/debug/librust_module.so /usr/local/lib/librust_module.so

0 commit comments

Comments
 (0)