forked from pyrsia/pyrsia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (52 loc) · 1.86 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
# syntax=docker/dockerfile:1.4.1
FROM rust:1.66.1-buster AS builder
ENV CARGO_TARGET_DIR=/target
WORKDIR /src
RUN apt-get update && apt-get install -y \
clang \
libclang-dev \
cmake \
protobuf-compiler
FROM builder AS debug
COPY . .
FROM builder AS dupdatelock
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/cache \
--mount=type=cache,target=/usr/local/cargo/registry/index \
cargo update
FROM scratch AS updatelock
COPY --from=dupdatelock /src/Cargo.lock .
FROM builder AS dbuild
RUN mkdir -p /out
ENV RUST_BACKTRACE=1
ENV DEV_MODE=on
ENV PYRSIA_ARTIFACT_PATH=pyrsia
ENV PYRSIA_BLOCKCHAIN_PATH=pyrsia/blockchain
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -; \
apt-get install -y -q nodejs; \
npm i -g toml-cli; \
rustup default $(cat Cargo.toml | toml | jq -r 'try(.package."rust-version") // "stable"')
RUN --mount=target=/src \
--mount=type=cache,target=/target \
--mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/cache \
--mount=type=cache,target=/usr/local/cargo/registry/index \
cargo build --profile=release --package=pyrsia_node && cp /target/release/pyrsia_node /out/
FROM debian:buster-slim AS node
ENV RUST_LOG=info
RUN <<EOT bash
set -e
apt-get update
apt-get install -y \
ca-certificates jq curl dnsutils
rm -rf /var/lib/apt/lists/*
EOT
COPY --from=dbuild /out/pyrsia_node /usr/bin/
COPY installers/docker/node-entrypoint.sh /tmp/entrypoint.sh
RUN chmod 755 /tmp/entrypoint.sh; mkdir -p /usr/local/var/pyrsia
WORKDIR /usr/local/var
ENV PYRSIA_ARTIFACT_PATH /usr/local/var/pyrsia
ENV PYRSIA_BLOCKCHAIN_PATH /usr/local/var/pyrsia/blockchain
ENV RUST_LOG debug
ENTRYPOINT [ "/tmp/entrypoint.sh", "--host", "0.0.0.0", "--listen", "/ip4/0.0.0.0/tcp/44000" ]