Break up Dockerfile into (additional) test and build images

This commit is contained in:
Deirdre Connolly 2020-11-18 14:41:47 -05:00 committed by Deirdre Connolly
parent 4c9bb87df2
commit a23de13af9
2 changed files with 61 additions and 0 deletions

39
docker/Dockerfile.build Normal file
View File

@ -0,0 +1,39 @@
# Builder image
FROM rust:buster as builder
RUN apt-get update && \
apt-get install -y --no-install-recommends \
make cmake g++ gcc llvm libclang-dev
RUN mkdir /zebra
WORKDIR /zebra
ENV RUST_BACKTRACE 1
ENV CARGO_HOME /zebra/.cargo/
RUN rustc -V; cargo -V; rustup -V
COPY . .
RUN cargo build --release
# Runner image
FROM debian:buster-slim AS zebrad-release
COPY --from=builder /zebra/target/release/zebrad /
ARG CHECKPOINT_SYNC=true
ARG NETWORK=Mainnet
RUN printf "[consensus]\n" >> /zebrad.toml
RUN printf "checkpoint_sync = ${CHECKPOINT_SYNC}\n" >> /zebrad.toml
RUN printf "[network]\n" >> /zebrad.toml
RUN printf "network = '${NETWORK}'\n" >> /zebrad.toml
RUN printf "[state]\n" >> /zebrad.toml
RUN printf "cache_dir = '/zebrad-cache'\n" >> /zebrad.toml
RUN printf "memory_cache_bytes = 52428800\n" >> /zebrad.toml
RUN printf "[tracing]\n" >> /zebrad.toml
RUN printf "endpoint_addr = '0.0.0.0:3000'\n" >> /zebrad.toml
EXPOSE 3000 8233 18233
CMD [ "/zebrad", "-c", "/zebrad.toml", "start" ]

22
docker/Dockerfile.test Normal file
View File

@ -0,0 +1,22 @@
FROM rustlang/rust:nightly
RUN apt-get update && \
apt-get install -y --no-install-recommends \
make cmake g++ gcc llvm libclang-dev
RUN mkdir /zebra
WORKDIR /zebra
ENV RUST_BACKTRACE 1
ENV CARGO_HOME /zebra/.cargo/
RUN rustc -V; cargo -V; rustup -V
EXPOSE 8233 18233
COPY . .
RUN cargo test --all --no-run
RUN find /zebra/target/debug/deps -type f -perm 755 ! -name '*.dylib' ! -name '*.so' | sed -e 'p;s/-.*//' | xargs -n2 mv
# Filtering to only run integration tests requires nightly for now
CMD ["cargo", "+nightly", "test", "--test", "'*'", "--no-fail-fast", "--", "-Zunstable-options", "--include-ignored"]