Skip to content

Commit 9479172

Browse files
authored
Merge pull request #14 from ClubeBitcoinUnB/refactor/separate-peer-build
Separate peer observer build from btc core build
2 parents 2cb65a8 + 126a504 commit 9479172

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

docker/bitcoin-node.dockerfile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
### Build stage ###
2-
FROM ubuntu:22.04 AS builder
1+
### Build stage (btc core) ###
2+
FROM ubuntu:22.04 AS btc-core-builder
33

44
ENV DEBIAN_FRONTEND=noninteractive
55
ARG BTC_CORE_TAG=v29.0
6-
ARG PEER_EXTRACTOR_REPO=https://github.com/0xB10C/peer-observer.git
7-
ARG PEER_EXTRACTOR_BRANCH=master
86

97
# Install build dependencies
108
RUN apt-get update && apt-get install -y \
@@ -25,10 +23,18 @@ RUN git clone --branch $BTC_CORE_TAG --depth=1 https://github.com/bitcoin/bitcoi
2523
RUN cmake -B build -DBUILD_GUI=OFF -DWITH_USDT=ON -DCMAKE_BUILD_TYPE=Debug && \
2624
cmake --build build -j$(nproc)
2725

26+
27+
### Build stage (peer-observer) ###
28+
FROM ubuntu:22.04 AS peer-observer-builder
29+
30+
ARG PEER_EXTRACTOR_REPO=https://github.com/0xB10C/peer-observer.git
31+
ARG PEER_EXTRACTOR_BRANCH=master
32+
2833
# Install peer-extractor dependencies
2934
RUN apt-get update && apt-get install -y \
3035
sudo git curl protobuf-compiler \
3136
clang elfutils libbpf-dev \
37+
cmake pkgconf \
3238
&& rm -rf /var/lib/apt/lists/*
3339

3440
# Install Rust
@@ -37,7 +43,7 @@ ENV PATH="/root/.cargo/bin:${PATH}"
3743
RUN rustup default stable
3844
RUN rustup component add rustfmt
3945

40-
# Copy the local repository to the container
46+
# Copy repository to the container
4147
RUN git clone -b $PEER_EXTRACTOR_BRANCH --single-branch $PEER_EXTRACTOR_REPO /peer-observer
4248

4349
# Set working directory to the repository
@@ -80,10 +86,10 @@ RUN useradd -m -s /bin/bash bitcoin \
8086
&& chown -R bitcoin:bitcoin /home/bitcoin /shared
8187

8288
# Copy everything we need from builder
83-
COPY --from=builder /peer-observer/scripts/bitcoin-node-entrypoint.sh /peer-observer/scripts/bitcoin-node-entrypoint.sh
84-
COPY --from=builder /peer-observer/scripts/bitcoin-node-healthcheck.sh /peer-observer/scripts/bitcoin-node-healthcheck.sh
85-
COPY --from=builder /bitcoin/build/bin/ /shared/
86-
COPY --from=builder /peer-observer/target/release/ebpf-extractor /usr/local/bin/ebpf-extractor
89+
COPY --from=peer-observer-builder /peer-observer/scripts/bitcoin-node-entrypoint.sh /peer-observer/scripts/bitcoin-node-entrypoint.sh
90+
COPY --from=peer-observer-builder /peer-observer/scripts/bitcoin-node-healthcheck.sh /peer-observer/scripts/bitcoin-node-healthcheck.sh
91+
COPY --from=peer-observer-builder /peer-observer/target/release/ebpf-extractor /usr/local/bin/ebpf-extractor
92+
COPY --from=btc-core-builder /bitcoin/build/bin/ /shared/
8793

8894
# Expose Bitcoin ports (RPC: 8332, P2P: 8333)
8995
EXPOSE 8332 8333

docker/peer-observer-tools.dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM rust:1.87.0-slim-bookworm AS builder
22

3+
ARG PEER_EXTRACTOR_REPO=https://github.com/0xB10C/peer-observer.git
4+
ARG PEER_EXTRACTOR_BRANCH=master
5+
36
# Install dependencies
47
RUN apt-get update && apt-get install -y \
58
build-essential \
@@ -9,8 +12,8 @@ RUN apt-get update && apt-get install -y \
912
# Create a non-root user and configure sudo
1013
RUN useradd -m -s /bin/bash appuser
1114

12-
# Copy the local repository to the container
13-
RUN git clone https://github.com/0xB10C/peer-observer.git
15+
# Copy repository to the container
16+
RUN git clone -b $PEER_EXTRACTOR_BRANCH --single-branch $PEER_EXTRACTOR_REPO /peer-observer
1417
RUN chown -R appuser:appuser /peer-observer
1518
USER appuser
1619

0 commit comments

Comments
 (0)