Skip to content

Commit

Permalink
[dockerfile] Improve validator-testing image build speed (aptos-labs#…
Browse files Browse the repository at this point in the history
…5982)

Currently, the validator-image is built each time because the previous step invalidates the cache. This increases build time as the bcc tools should be built every single time.

This change moves the bcc tools and apt-get install steps into a separate build called validator-testing-base and builds the validator-testing image on top of this image. This however means that we need to duplicate steps from validator image to the validator-testing image, but I think we can accept this tradeoff for reduced build times.
  • Loading branch information
ibalajiarun authored Dec 27, 2022
1 parent d08e5aa commit 1cdfc2b
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions docker/rust-all.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,19 @@ ENV GIT_SHA ${GIT_SHA}

### EXPERIMENTAL ###

### Validator Image ###
FROM validator AS validator-testing
FROM debian-base as validator-testing-base

RUN apt-get update && apt-get install -y \
libssl1.1 \
ca-certificates \
# Needed to run debugging tools like perf
linux-perf \
sudo \
procps \
gdb \
curl \
# postgres client lib required for indexer
libpq-dev \
# Extra goodies for debugging
less \
git \
Expand All @@ -296,6 +305,10 @@ RUN apt-get update && apt-get install -y \
valgrind \
&& apt-get clean && rm -r /var/lib/apt/lists/*

### Because build machine perf might not match run machine perf, we have to symlink
### Even if version slightly off, still mostly works
RUN ln -sf /usr/bin/perf_* /usr/bin/perf

RUN echo "deb http://deb.debian.org/debian sid main contrib non-free" >> /etc/apt/sources.list
RUN echo "deb-src http://deb.debian.org/debian sid main contrib non-free" >> /etc/apt/sources.list

Expand All @@ -317,6 +330,39 @@ RUN make
RUN make install
WORKDIR ..

### Validator Image ###
# We will build a base testing image with the necessary packages and
# duplicate steps from validator step. This will, however, reduce
# cache invalidation and reduce build times.
FROM validator-testing-base AS validator-testing

RUN addgroup --system --gid 6180 aptos && adduser --system --ingroup aptos --no-create-home --uid 6180 aptos

RUN mkdir -p /opt/aptos/etc
COPY --link --from=builder /aptos/dist/aptos-node /usr/local/bin/
COPY --link --from=builder /aptos/dist/db-backup /usr/local/bin/
COPY --link --from=builder /aptos/dist/aptos-db-bootstrapper /usr/local/bin/
COPY --link --from=builder /aptos/dist/db-restore /usr/local/bin/

# Admission control
EXPOSE 8000
# Validator network
EXPOSE 6180
# Metrics
EXPOSE 9101
# Backup
EXPOSE 6186

# add build info
ARG BUILD_DATE
ENV BUILD_DATE ${BUILD_DATE}
ARG GIT_TAG
ENV GIT_TAG ${GIT_TAG}
ARG GIT_BRANCH
ENV GIT_BRANCH ${GIT_BRANCH}
ARG GIT_SHA
ENV GIT_SHA ${GIT_SHA}

# Capture backtrace on error
ENV RUST_BACKTRACE 1
ENV RUST_LOG_FORMAT=json

0 comments on commit 1cdfc2b

Please sign in to comment.