Skip to content

Commit 0d6dab9

Browse files
committed
Add stratum-bridge dockerfile
1 parent a86c97c commit 0d6dab9

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

‎docker/Dockerfile.stratum-bridge‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ---------------------------------------- Chef image -------------------------------------------
2+
FROM rust:1.90-alpine AS chef
3+
RUN apk --no-cache add \
4+
musl-dev \
5+
protobuf-dev \
6+
g++ \
7+
clang15-dev \
8+
linux-headers \
9+
wasm-pack \
10+
openssl-dev
11+
RUN cargo install cargo-chef --locked
12+
WORKDIR /app
13+
14+
# ---------------------------------------- Planner image ----------------------------------------
15+
FROM chef AS planner
16+
COPY . .
17+
RUN cargo chef prepare --recipe-path recipe.json
18+
19+
# ---------------------------------------- Builder image ----------------------------------------
20+
FROM chef AS builder
21+
COPY --from=planner /app/recipe.json recipe.json
22+
23+
ENV RUSTFLAGS="-C target-feature=-crt-static" \
24+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse"
25+
26+
# Build dependencies - this is the caching Docker layer
27+
RUN cargo chef cook --release --recipe-path recipe.json -p kaspa-stratum-bridge --bin stratum-bridge
28+
29+
COPY . .
30+
RUN --mount=type=cache,id=cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
31+
--mount=type=cache,id=cargo-git,target=/usr/local/cargo/git,sharing=locked \
32+
--mount=type=cache,id=cargo-target,target=/app/target,sharing=locked \
33+
cargo build --release --bin stratum-bridge \
34+
&& cp /app/target/release/stratum-bridge /app/stratum-bridge # <-- outside the mount, persists
35+
36+
37+
# ---------------------------------------- Runtime image ----------------------------------------
38+
FROM alpine AS runtime
39+
WORKDIR /app
40+
41+
RUN apk --no-cache add \
42+
libgcc \
43+
libstdc++ \
44+
tini \
45+
ca-certificates \
46+
&& addgroup -S kaspa \
47+
&& adduser -S -G kaspa -h /home/kaspa -s /sbin/nologin kaspa \
48+
&& mkdir -p /home/kaspa /app \
49+
&& chown -R kaspa:kaspa /home/kaspa /app
50+
51+
COPY --from=builder --chown=kaspa:kaspa /app/stratum-bridge .
52+
53+
ENV HOME=/home/kaspa
54+
USER kaspa
55+
ENTRYPOINT [ "/sbin/tini", "--" ]
56+
CMD [ "/app/stratum-bridge" ]

0 commit comments

Comments
 (0)