2024-04-24 11:41:25 +00:00
|
|
|
FROM golang:1.21-bullseye AS chain-builder
|
2023-06-14 16:37:21 +00:00
|
|
|
|
|
|
|
# Set up dependencies
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y git make gcc libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# Set working directory for the build
|
|
|
|
WORKDIR /root
|
|
|
|
# default home directory is /root
|
|
|
|
|
|
|
|
# install rocksdb
|
2024-02-06 22:54:10 +00:00
|
|
|
ARG rocksdb_version=v8.10.0
|
2023-06-14 16:37:21 +00:00
|
|
|
ENV ROCKSDB_VERSION=$rocksdb_version
|
|
|
|
|
|
|
|
RUN git clone https://github.com/facebook/rocksdb.git \
|
|
|
|
&& cd rocksdb \
|
|
|
|
&& git checkout $ROCKSDB_VERSION \
|
|
|
|
&& make -j$(nproc) install-shared \
|
|
|
|
&& ldconfig
|
|
|
|
|
2024-04-24 11:41:25 +00:00
|
|
|
WORKDIR /root/0gchain
|
2023-11-08 22:06:03 +00:00
|
|
|
# Copy dependency files first to facilitate dependency caching
|
|
|
|
COPY ./go.mod ./
|
|
|
|
COPY ./go.sum ./
|
|
|
|
|
|
|
|
# Download dependencies
|
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
|
|
|
go version && go mod download
|
|
|
|
|
|
|
|
# Add source files
|
|
|
|
COPY . .
|
2023-06-14 16:37:21 +00:00
|
|
|
|
2024-04-24 11:41:25 +00:00
|
|
|
ARG 0gchain_database_backend=rocksdb
|
|
|
|
ENV 0GCHAIN_DATABASE_BACKEND=$0gchain_database_backend
|
2023-06-14 16:37:21 +00:00
|
|
|
|
|
|
|
# Mount go build and mod caches as container caches, persisted between builder invocations
|
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2024-04-24 11:41:25 +00:00
|
|
|
make install COSMOS_BUILD_OPTIONS=$0GCHAIN_DATABASE_BACKEND
|
2023-06-14 16:37:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
FROM ubuntu:22.04
|
|
|
|
|
2024-05-13 21:56:28 +00:00
|
|
|
# Install necessary libraries
|
2023-06-14 16:37:21 +00:00
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y libsnappy1v5 libgflags2.2 zlib1g libbz2-1.0 curl jq \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# copy rocksdb shared objects
|
2024-04-24 11:41:25 +00:00
|
|
|
COPY --from=chain-builder /usr/local/lib/ /usr/local/lib/
|
2023-06-14 16:37:21 +00:00
|
|
|
RUN ldconfig
|
|
|
|
|
2024-04-24 11:41:25 +00:00
|
|
|
# copy 0g-chain binary
|
|
|
|
COPY --from=chain-builder /go/bin/0gchaind /bin/0gchaind
|
2023-06-14 16:37:21 +00:00
|
|
|
|
2024-05-13 21:56:28 +00:00
|
|
|
# Command to run the binary
|
2024-04-24 11:41:25 +00:00
|
|
|
CMD ["0gchaind"]
|