forked from bnb-chain/node-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (68 loc) · 2.94 KB
/
Dockerfile
File metadata and controls
81 lines (68 loc) · 2.94 KB
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
75
76
77
78
79
80
81
# Multi-stage Dockerfile for BSC Node
# Stage 1: Build Environment with all required tools
# We use Python 3.12 as the base to fulfill the requirement, then add Go 1.24
FROM python:3.12-bookworm AS build-env
# Arguments for versions
ARG NODE_VERSION=16.x
ARG GO_VERSION=1.24.0
# Install Go 1.24 (Detect architecture to support both x86_64 and arm64)
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "x86_64" ]; then GO_ARCH="amd64"; else GO_ARCH="arm64"; fi && \
curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz | tar -C /usr/local -xz
ENV PATH="/usr/local/go/bin:$PATH"
# Install basic dependencies
RUN apt-get update && apt-get install -y \
curl \
git \
make \
jq \
build-essential \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js (README mentions v16.15.0)
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - && \
apt-get install -y nodejs && \
npm install -g npm@6.14.6
# Install Poetry using its official installer
# (Python 3.12 is already the system default in this image)
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="/root/.local/bin:$PATH"
# Install Foundry (Ethereum development toolkit)
# This is needed because BSC's system contracts (in the genesis/ folder) use 'forge' to compile.
RUN curl -L https://foundry.paradigm.xyz | bash && \
/root/.foundry/bin/foundryup
ENV PATH="/root/.foundry/bin:$PATH"
ENV PATH="/node_deploy/bin:$PATH"
# Setting up the workspace
WORKDIR /node_deploy
# Copy and install Python requirements
# This avoids installing them manually every time you restart the container.
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# Build and install the validator tool
# By installing to /usr/local/bin, we ensure the binary is available even if the
# /node_deploy directory is shadowed by a volume mount from the host.
COPY create-validator/ ./create-validator/
RUN cd create-validator && go build -o /usr/local/bin/create-validator
# Copy entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Tool verification command
# This ensures that when the image is built, all required tools are present and functional.
RUN go version && \
node -v && \
npm -v && \
python3 --version && \
poetry --version && \
forge --version && \
jq --version && \
create-validator --help
# Add init check to .bashrc to warn users when they login
RUN echo 'if [ -f /tmp/cluster_initializing ]; then' >> /root/.bashrc && \
echo ' echo "----------------------------------------------------"' >> /root/.bashrc && \
echo ' echo " WARNING: Cluster is still initializing. Please wait! "' >> /root/.bashrc && \
echo ' echo "----------------------------------------------------"' >> /root/.bashrc && \
echo ' echo ""' >> /root/.bashrc && \
echo 'fi' >> /root/.bashrc
# Default command: show help or just stay open
CMD ["bash"]