0g-chain/Dockerfile-rocksdb
Robert Pirtle 967c6857e8
ci: update CI workflows and pipelines (#1768)
* build & publish rocksdb docker images merge to master
* publish docker images on push of release version tags

NOTE: New docker image tag pattern. ALL tags now include database suffix
ex. <githash>-goleveldb, v0.25.0-alpha.1-rocksdb, master-rocksdb, etc

* update dockerfiles for better caching
* update all github action workflow versions
* improve caching of go packages
* cache docker image layers for reuse between runs
* update dockerignore to remove non-essential files
2023-11-08 14:06:03 -08:00

58 lines
1.5 KiB
Plaintext

FROM golang:1.20-bullseye AS kava-builder
# 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
ARG rocksdb_version=v8.1.1
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
WORKDIR /root/kava
# 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 . .
ARG kava_database_backend=rocksdb
ENV KAVA_DATABASE_BACKEND=$kava_database_backend
# 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 \
make install COSMOS_BUILD_OPTIONS=$KAVA_DATABASE_BACKEND
FROM ubuntu:22.04
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
COPY --from=kava-builder /usr/local/lib/ /usr/local/lib/
RUN ldconfig
# copy kava binary
COPY --from=kava-builder /go/bin/kava /bin/kava
CMD ["kava"]