-
Notifications
You must be signed in to change notification settings - Fork 58
/
Dockerfile
61 lines (48 loc) · 2.04 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
# --- Build stage ---
FROM rust:latest AS build-stage
WORKDIR /opt/rusk
ENV RUSK_PROFILE_PATH /.dusk/rusk
RUN apt-get update && apt-get install -y clang && rm -rf /var/lib/apt/lists/*
COPY . .
ARG TARGETPLATFORM
# See also https://github.com/docker/buildx/issues/510
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
# Features to include in the build
# E.g., --build-arg CARGO_FEATURES="archive"
ARG CARGO_FEATURES="archive"
# Convert Docker platform arg to Rust target name,
# and install nightly based on the Rust target
RUN ARCH="$(echo $TARGETPLATFORM | sed 's/linux\///')" && \
case "$ARCH" in \
"amd64") RUST_ARCH="x86_64";; \
"arm64") RUST_ARCH="aarch64";; \
"arm/v7") RUST_ARCH="armv7";; \
*) echo "Unsupported architecture: $ARCH"; exit 1 ;; \
esac && \
RUST_TARGET="$RUST_ARCH-unknown-linux-gnu" && \
echo "Rust target: $RUST_TARGET" && \
rustup toolchain install nightly-2023-05-22-$RUST_TARGET && \
rustup component add rust-src --toolchain nightly-2023-05-22-$RUST_TARGET
# Generate keys and compile genesis contracts
RUN make keys
RUN make wasm
# Build rusk with default features and include CARGO_FEATURES
RUN if [ -n "$CARGO_FEATURES" ]; then \
cargo build --release --features "$CARGO_FEATURES" -p rusk; \
else \
cargo build --release -p rusk; \
fi
# --- Run stage ---
FROM debian:bookworm-slim
WORKDIR /opt/rusk
ENV RUSK_PROFILE_PATH /.dusk/rusk/
ENV DUSK_CONSENSUS_KEYS_PASS password
EXPOSE 9000/udp
EXPOSE 8080/tcp
RUN apt-get update && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
# Copy only the necessary files from the build stage
COPY --from=build-stage /.dusk/rusk /.dusk/rusk
COPY --from=build-stage /opt/rusk/target/release/rusk /opt/rusk/
COPY --from=build-stage /opt/rusk/examples/consensus.keys /opt/rusk/consensus.keys
COPY --from=build-stage /opt/rusk/examples/genesis.toml /opt/rusk/state.toml
CMD ./rusk recovery state --init /opt/rusk/state.toml -o /tmp/state; ./rusk -s /tmp/state --consensus-keys-path /opt/rusk/consensus.keys --http-listen-addr 0.0.0.0:8080