forked from afitzek/hasura-metric-adapter
-
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.
- Loading branch information
Showing
5 changed files
with
49 additions
and
8 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 |
---|---|---|
@@ -1,19 +1,30 @@ | ||
FROM rust:1.58 as build | ||
# syntax=docker/dockerfile:1 | ||
|
||
RUN echo "export PATH=/usr/local/cargo/bin:$PATH" >> /etc/profile | ||
FROM --platform=$BUILDPLATFORM rust:1.58 as build | ||
ARG TARGETARCH | ||
|
||
RUN echo "export PATH=/usr/local/cargo/bin:$PATH" >> /etc/profile | ||
WORKDIR /app | ||
|
||
COPY ["./build/platform.sh", "./"] | ||
RUN ./platform.sh | ||
COPY ["./build/.cargo/config", ".cargo/config"] | ||
RUN rustup target add $(cat /.platform) | ||
RUN apt-get update && apt-get install -y $(cat /.compiler) | ||
|
||
COPY ["./metrics/Cargo.toml", "./metrics/Cargo.lock", "./"] | ||
|
||
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release | ||
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release --target=$(cat /.platform) | ||
|
||
COPY ["./metrics/src", "./src"] | ||
|
||
RUN touch src/main.rs && cargo build --release | ||
RUN touch src/main.rs && cargo build --release --target=$(cat /.platform) | ||
|
||
FROM gcr.io/distroless/cc-debian11 | ||
RUN mkdir -p /release/$TARGETARCH | ||
RUN cp ./target/$(cat /.platform)/release/metrics /release/$TARGETARCH/metrics | ||
|
||
COPY --from=build /app/target/release/metrics / | ||
FROM gcr.io/distroless/cc-debian11 | ||
ARG TARGETARCH | ||
COPY --from=build /release/$TARGETARCH/metrics / | ||
|
||
CMD ["/metrics"] | ||
CMD ["/metrics"] |
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,5 @@ | ||
[target.armv7-unknown-linux-gnueabihf] | ||
linker = "arm-linux-gnueabihf-gcc" | ||
|
||
[target.aarch64-unknown-linux-gnu] | ||
linker = "aarch64-linux-gnu-gcc" |
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,19 @@ | ||
#!/bin/bash | ||
|
||
# Used in Docker build to set platform dependent variables | ||
|
||
case $TARGETARCH in | ||
|
||
"amd64") | ||
echo "x86_64-unknown-linux-gnu" > /.platform | ||
echo "" > /.compiler | ||
;; | ||
"arm64") | ||
echo "aarch64-unknown-linux-gnu" > /.platform | ||
echo "gcc-aarch64-linux-gnu" > /.compiler | ||
;; | ||
"arm") | ||
echo "armv7-unknown-linux-gnueabihf" > /.platform | ||
echo "gcc-arm-linux-gnueabihf" > /.compiler | ||
;; | ||
esac |
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