This repository has been archived by the owner on May 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (51 loc) · 1.78 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# build stage
FROM --platform=$BUILDPLATFORM lukemathwalker/cargo-chef:latest-rust-bullseye AS chef
WORKDIR /build/
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libprotobuf-dev \
protobuf-compiler \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install buf cli
RUN BIN="/usr/local/bin" && \
VERSION="1.17.0" && \
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \
-o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
# install zig
RUN curl -L "https://ziglang.org/download/0.10.1/zig-linux-$(uname -m)-0.10.1.tar.xz" | tar -J -x -C /usr/local && \
ln -s "/usr/local/zig-linux-$(uname -m)-0.10.1/zig" /usr/local/bin/zig
# install zigbuild
RUN cargo install --locked cargo-zigbuild
# install targets
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef as builder
COPY --from=planner /build/recipe.json recipe.json
ARG TARGETPLATFORM
RUN case "$TARGETPLATFORM" in \
"linux/arm64") target="aarch64-unknown-linux-gnu" ;; \
"linux/amd64") target="x86_64-unknown-linux-gnu" ;; \
esac \
&& printf "$target" > target_triple \
&& rustup target add "$target" \
&& cargo chef cook --zigbuild \
--release \
--target "$target" \
--recipe-path recipe.json
COPY . .
RUN cargo zigbuild --release \
--target $(cat ./target_triple) \
--bin conductor
# replace this with `--out` or `--out-dir` once stable
RUN mkdir -p target/release \
&& cp target/$(cat ./target_triple)/release/conductor target/release/
# TODO - remove debug tag once this is stable
FROM gcr.io/distroless/cc:debug
WORKDIR /app/
EXPOSE 2450
COPY --from=builder /build/target/release/conductor /usr/local/bin/conductor
ENTRYPOINT ["/usr/local/bin/conductor"]