forked from polat272/penumbra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.dev
74 lines (63 loc) · 2.49 KB
/
Dockerfile.dev
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
74
FROM rust:latest as build
# Specify the cargo cache dir as a volume to improve build speed
VOLUME ["/root/.cargo"]
RUN curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path --default-toolchain none -y
RUN rustup component add rustfmt
RUN apt-get update && apt-get install -y clang libclang-dev
WORKDIR /usr/src
# Use a dummy entrypoint to build each crate, that way dependencies can be cached
# without code changes causing a complete rebuild.
# TODO all these COPY commands add additional layers to the image. I'm not sure
# how big they are but for the distributed images we likely want to use
# a simpler Dockerfile.
COPY Cargo.toml .
RUN mkdir -p pcli/src pd/src &&\
echo "fn main() {}" > pcli/src/main.rs &&\
echo "fn main() {}" > pd/src/main.rs
COPY pcli/build.rs ./pcli
COPY pcli/Cargo.toml ./pcli
COPY pd/Cargo.toml ./pd
COPY pd/build.rs ./pd
# TODO If the protobuf definitions, crypto, or wallet implementations change,
# there will be a complete rebuild. This is maybe possible to avoid.
COPY proto ./proto
COPY chain ./chain
COPY crypto ./crypto
COPY custody ./custody
COPY component ./component
COPY storage ./storage
COPY tct ./tct
COPY decaf377-fmd ./decaf377-fmd
COPY decaf377-ka ./decaf377-ka
COPY tct-property-test ./tct-property-test
COPY transaction ./transaction
COPY wallet ./wallet
COPY view ./view
COPY testnets ./testnets
COPY .git ./.git
COPY testnets ./testnets
COPY .cargo ./.cargo
# Sorry about all that mess ^, but it's worth it during development.
# Fetch dependencies in a separate layer, so that they can be cached.
RUN cargo fetch
RUN cargo build --release --bin pd
# Remove the cached builds of internal packages.
RUN rm -rf pcli pd crypto wallet config stake ibc component storage
# Copy the repo source now that dependencies have been built and cached.
COPY . .
# For dev leave off the `--release` flag as well for faster builds.
RUN cargo build --release --bin pd && \
mkdir -p /out && \
mv target/release/pd /out/pd
# Install the penumbra daemon into the runtime image.
# TODO(eliza): it would be nice to be able to run the Penumbra daemon in a
# `scratch` image rather than Debian or Alpine. However, then we'd have to build
# with a statically linked libc (read: musl), and musl's malloc exhibits
# pathologically poor performance for Tokio applications...
FROM debian:bullseye-slim as runtime
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
WORKDIR /penumbra
COPY --from=build /out/pd /usr/bin/pd
ENV RUST_LOG=warn,pd=info,penumbra=info
CMD [ "RUST_BACKTRACE=1 /usr/bin/pd" ]