-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
64 lines (41 loc) · 1.9 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
60
61
62
63
64
# https://www.lpalmieri.com/posts/fast-rust-docker-builds/#cargo-chef
FROM --platform=$BUILDPLATFORM lukemathwalker/cargo-chef:0.1.67-rust-1.80.1-slim-bookworm AS chef
WORKDIR /app
FROM --platform=$BUILDPLATFORM chef AS planner
COPY Cargo.toml .
COPY Cargo.lock .
COPY crates ./crates
RUN cargo chef prepare --recipe-path recipe.json
FROM --platform=$BUILDPLATFORM chef AS builder
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get -y install build-essential protobuf-compiler
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY Cargo.toml .
COPY Cargo.lock .
COPY crates ./crates
RUN cargo build --release --bin sqd-bootnode --bin sqd-keygen --bin sqd-observer
FROM --platform=$BUILDPLATFORM debian:bookworm-slim AS base
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get -y install ca-certificates net-tools
FROM --platform=$BUILDPLATFORM base AS bootnode
COPY --from=builder /app/target/release/sqd-bootnode /usr/local/bin/bootnode
COPY --from=builder /app/target/release/sqd-keygen /usr/local/bin/keygen
CMD ["bootnode"]
ENV P2P_LISTEN_ADDRS="/ip4/0.0.0.0/udp/12345/quic-v1"
COPY p2p_healthcheck.sh ./healthcheck.sh
RUN chmod +x ./healthcheck.sh
HEALTHCHECK --interval=5s CMD ./healthcheck.sh
FROM --platform=$BUILDPLATFORM base AS observer
COPY --from=builder /app/target/release/sqd-observer /usr/local/bin/sqd-observer
CMD ["sqd-observer"]
ENV P2P_LISTEN_ADDRS="/ip4/0.0.0.0/udp/12345/quic-v1"
FROM --platform=$BUILDPLATFORM base AS keygen
COPY --from=builder /app/target/release/sqd-keygen /usr/local/bin/keygen
ENTRYPOINT ["keygen"]