This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (48 loc) · 1.95 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
# syntax=docker/dockerfile:1.4
FROM rust:latest AS env
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt update \
&& apt install --yes --no-install-recommends \
protobuf-compiler
RUN wget -qO- "https://github.com/mozilla/sccache/releases/download/v0.4.2/sccache-v0.4.2-$(uname -m)-unknown-linux-musl.tar.gz" \
| tar xzC /usr/local/bin/ --strip-components 1 "sccache-v0.4.2-$(uname -m)-unknown-linux-musl/sccache" \
&& chmod +x /usr/local/bin/sccache
ENV RUSTC_WRAPPER=/usr/local/bin/sccache
ENV SCCACHE_DIR=/var/cache/sccache
WORKDIR /app
FROM env AS contracts
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=${SCCACHE_DIR} \
cargo install \
--git https://github.com/foundry-rs/foundry foundry-cli \
--profile local \
--bin forge \
--locked
COPY --link ./foundry.toml ./remappings.txt ./
COPY --link ./contracts/ ./contracts/
RUN --mount=type=cache,target=./contracts/cache forge build
FROM env AS builder
COPY --link ./rust-toolchain.toml ./
RUN --mount=type=cache,target=/usr/local/rustup \
rustup set profile minimal \
&& rustup show active-toolchain
COPY --link . .
COPY --from=contracts --link /app/contracts/out/ ./contracts/out/
RUN --mount=type=cache,target=/usr/local/rustup \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=${SCCACHE_DIR} \
--mount=type=cache,target=./target \
cargo build --locked --release --bin sandwitch \
&& mv ./target/release/sandwitch /usr/local/bin/
FROM gcr.io/distroless/cc
COPY --from=builder /usr/local/bin/sandwitch /usr/local/bin/
VOLUME [ "/etc/sandwitch" ]
ENTRYPOINT [\
"/usr/local/bin/sandwitch",\
"--config", "/etc/sandwitch/sandwitch.toml"\
]
EXPOSE 9000/tcp
HEALTHCHECK --interval=15s --timeout=5s \
CMD curl -sf http://127.0.0.1:9000/metrics || exit 1