-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for building and deploying on ARM
- Loading branch information
1 parent
c71925a
commit da17cd2
Showing
3 changed files
with
18 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[target.aarch64-unknown-linux-gnu] | ||
pre-build = [ | ||
"apt update && apt install -y protobuf-compiler" | ||
] | ||
|
||
[target.x86_64-unknown-linux-gnu] | ||
pre-build = [ | ||
"apt update && apt install -y protobuf-compiler" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,34 @@ | ||
FROM clux/muslrust:stable as builder | ||
|
||
ARG PROTOC_VERSION=3.20.2 | ||
|
||
RUN apt-get update && apt-get install -y openssl unzip | ||
|
||
# Install protoc | ||
RUN curl -sSL -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip" && unzip /tmp/protoc.zip -d /usr/local && rm /tmp/protoc.zip | ||
RUN apt-get update && apt-get install -y openssl unzip protobuf-compiler | ||
|
||
WORKDIR /src | ||
|
||
# Pre-build all dependencies | ||
RUN USER=root cargo init --bin --name bender | ||
COPY ./Cargo.lock . | ||
COPY ./Cargo.toml . | ||
RUN cargo build --release --locked && rm -rf target/x86_64-unknown-linux-musl/release/deps/bender* | ||
RUN cargo build --release --locked && rm -rf target/*/release/deps/bender* | ||
RUN rm src/*.rs | ||
|
||
# Add the source code | ||
COPY . . | ||
|
||
# Run the test suite | ||
RUN cargo test --release && rm -rf target/x86_64-unknown-linux-musl/release/deps/bender* | ||
RUN cargo test --release && rm -rf target/*/release/deps/bender* | ||
|
||
# Build the final executable of the project | ||
RUN cargo build --release --bin bender --locked | ||
|
||
# Ensure that the binary is at a known location for the next stage | ||
RUN mkdir /out && \ | ||
rm /src/target/x86_64-unknown-linux-musl/release/deps/bender*.d && \ | ||
cp /src/target/x86_64-unknown-linux-musl/release/deps/bender* /out/bender | ||
|
||
FROM alpine:latest | ||
rm /src/target/*/release/deps/bender*.d && \ | ||
cp /src/target/*/release/deps/bender* /out/bender | ||
|
||
RUN apk --no-cache add ca-certificates | ||
FROM cgr.dev/chainguard/static:latest | ||
|
||
COPY --from=builder /out/bender /app/bender | ||
ADD ./quotes.json /app/quotes.json | ||
|
||
WORKDIR /app | ||
CMD [ "/app/bender" ] | ||
ENTRYPOINT [ "/app/bender" ] |