forked from ZcashFoundation/z3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.zebra
More file actions
73 lines (56 loc) · 2.05 KB
/
Dockerfile.zebra
File metadata and controls
73 lines (56 loc) · 2.05 KB
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
65
66
67
68
69
70
71
72
73
# syntax=docker/dockerfile:1
# Zebra build from z3 root context (includes patched orchard/librustzcash)
ARG RUST_VERSION=1.89.0
ARG UID=10001
ARG GID=10001
ARG USER=zebra
ARG HOME=/home/zebra
############################
# Builder
############################
FROM rust:${RUST_VERSION}-bookworm AS builder
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
WORKDIR /build
# Build with internal-miner feature for Regtest mining
ARG FEATURES="default-release-binaries internal-miner"
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config clang cmake make libssl-dev ca-certificates \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
# Copy entire workspace (z3 root, including submodules)
COPY . .
# Build zebrad with internal-miner feature
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/target \
cargo install --locked --path zebra/zebrad --bin zebrad --root /out --features "${FEATURES}"
############################
# Runtime
############################
FROM debian:bookworm-slim AS runtime
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
ARG UID
ARG GID
ARG USER
ARG HOME
# Install runtime dependencies
RUN apt-get -qq update && \
apt-get -qq install -y --no-install-recommends \
ca-certificates libssl3 libgcc-s1 curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user (matching Zebra's expectations)
RUN addgroup --gid "${GID}" "${USER}" && \
adduser --uid "${UID}" --gid "${GID}" --home "${HOME}" \
--disabled-password --gecos "" "${USER}"
WORKDIR ${HOME}
# Copy the built binary
COPY --from=builder /out/bin/zebrad /usr/local/bin/zebrad
# Create cache directory
RUN mkdir -p ${HOME}/.cache/zebra && chown -R "${UID}:${GID}" "${HOME}"
USER ${USER}
# Expose ports (RPC, P2P, metrics, health)
EXPOSE 18232 18233 9999 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -sf http://127.0.0.1:8080/ready || exit 1
CMD ["zebrad", "start"]