|
1 | | -# We need to build in a Linux environment to support C libraries, e.g. RocksDB. |
2 | | -# We use Debian instead of Alpine, so that we can use binary database packages |
3 | | -# instead of spending time compiling them. |
4 | | -FROM cometbft/cometbft-db-testing:v1.0.4 |
| 1 | +# Multi-stage build Dockerfile for CometBFT debug end-to-end testing |
| 2 | +# Stage 1: Build environment - compiles the application and test node with debugging support |
| 3 | +FROM cometbft/cometbft-db-testing:v1.0.4 AS build |
5 | 4 |
|
6 | | -RUN apt-get -qq update -y && apt-get -qq upgrade -y >/dev/null |
7 | | -RUN apt-get -qq install -y zsh vim >/dev/null |
8 | | -RUN go install github.com/go-delve/delve/cmd/dlv@latest |
9 | | - |
10 | | -# Set up build directory /src/cometbft |
11 | | -ENV COMETBFT_BUILD_OPTIONS=badgerdb,rocksdb,nostrip,clock_skew,bls12381,secp256k1eth |
12 | 5 | WORKDIR /src/cometbft |
13 | 6 |
|
14 | | -# Fetch dependencies separately (for layer caching) |
15 | | -COPY go.mod go.sum ./ |
| 7 | +# Copy Go module files and download dependencies |
| 8 | +# This is done before copying the rest of the code to leverage Docker's build cache |
| 9 | +COPY go.mod go.sum api/go.mod api/go.sum ./ |
16 | 10 | RUN go mod download |
17 | 11 |
|
18 | | -# Build CometBFT and install into /usr/bin/cometbft |
| 12 | +# Copy the entire codebase into the container |
19 | 13 | COPY . . |
20 | | -RUN echo $COMETBFT_BUILD_OPTION && make build && cp build/cometbft /usr/bin/cometbft |
21 | | -COPY test/e2e/docker/entrypoint-delve /usr/bin/entrypoint-builtin |
22 | | -RUN cd test/e2e && make node && cp build/node /usr/bin/app |
23 | 14 |
|
24 | | -# Set up runtime directory. We don't use a separate runtime image since we need |
25 | | -# e.g. leveldb and rocksdb which are already installed in the build image. |
| 15 | +# Set build options to include specific features and databases |
| 16 | +ENV COMETBFT_BUILD_OPTIONS=badgerdb,rocksdb,clock_skew,bls12381,secp256k1eth,nostrip |
| 17 | +RUN make build |
| 18 | +RUN cd test/e2e && make node |
| 19 | + |
| 20 | +# Stage 2: Final image - runtime environment with debugging support |
| 21 | +FROM golang:1.23 AS runtime |
| 22 | + |
| 23 | +# Update system packages and install network utilities |
| 24 | +RUN apt-get -qq update -y && apt-get -qq upgrade -y >/dev/null |
| 25 | +RUN apt-get -qq install -y iputils-ping iproute2 >/dev/null |
| 26 | +RUN apt-get -qq install -y zsh vim >/dev/null |
| 27 | +RUN go install github.com/go-delve/delve/cmd/dlv@latest |
| 28 | + |
26 | 29 | WORKDIR /cometbft |
27 | 30 | VOLUME /cometbft |
28 | 31 | ENV CMTHOME=/cometbft |
| 32 | + |
| 33 | +# Configure Go race detector to halt on error |
29 | 34 | ENV GORACE="halt_on_error=1" |
30 | 35 |
|
| 36 | +# Copy RocksDB shared libraries from the build stage |
| 37 | +COPY --from=build /usr/local/lib/librocksdb.so* /lib/ |
| 38 | + |
| 39 | +# Copy executables from the build stage |
| 40 | +# - entrypoint script for container initialization |
| 41 | +# - cometbft binary for the blockchain node |
| 42 | +# - app binary for the test application |
| 43 | +COPY --from=build /src/cometbft/test/e2e/docker/entrypoint-delve /usr/bin/entrypoint-builtin |
| 44 | +COPY --from=build /src/cometbft/build/cometbft /usr/bin/cometbft |
| 45 | +COPY --from=build /src/cometbft/test/e2e/build/node /usr/bin/app |
| 46 | + |
| 47 | +# Expose ports: |
| 48 | +# - 26656: P2P communication between nodes |
| 49 | +# - 26657: RPC server for API requests |
| 50 | +# - 26660: ABCI server for application communication |
| 51 | +# - 6060: Prometheus metrics endpoint |
| 52 | +# - 2345, 2346: Delve debugger ports |
31 | 53 | EXPOSE 26656 26657 26660 6060 2345 2346 |
32 | 54 | STOPSIGNAL SIGTERM |
0 commit comments