From f72b628b710ef2ac3b59e83738e4e719d65e43f4 Mon Sep 17 00:00:00 2001 From: Robert Pirtle Date: Thu, 2 May 2024 10:36:49 -0700 Subject: [PATCH] ci: extract separate rocksdb base image (#1898) * docker: separate rocksdb base image from build * ci: inject go build cache for docker img builds --- .github/workflows/ci-docker.yml | 22 ++++++++++++++++++++++ Dockerfile-rocksdb | 21 ++------------------- Dockerfile-rocksdb-base | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 Dockerfile-rocksdb-base diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 067f6055..77f8f67a 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -50,6 +50,17 @@ jobs: username: ${{ inputs.dockerhub-username }} password: ${{ secrets.CI_DOCKERHUB_TOKEN }} + - name: Go Build Cache for Docker + uses: actions/cache@v3 + with: + path: go-build-cache + key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} + + - name: inject go-build-cache into docker + uses: reproducible-containers/buildkit-cache-dance@v2.1.2 + with: + cache-source: go-build-cache + # publish to docker hub, tag with short git hash - name: Build and push (goleveldb) uses: docker/build-push-action@v5 @@ -89,6 +100,17 @@ jobs: username: ${{ inputs.dockerhub-username }} password: ${{ secrets.CI_DOCKERHUB_TOKEN }} + - name: Go Build Cache for Docker + uses: actions/cache@v3 + with: + path: go-build-cache + key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} + + - name: inject go-build-cache into docker + uses: reproducible-containers/buildkit-cache-dance@v2.1.2 + with: + cache-source: go-build-cache + # publish to docker hub, tag with short git hash - name: Build and push (rocksdb) uses: docker/build-push-action@v5 diff --git a/Dockerfile-rocksdb b/Dockerfile-rocksdb index 89d0f3d2..0c4d1931 100644 --- a/Dockerfile-rocksdb +++ b/Dockerfile-rocksdb @@ -1,23 +1,6 @@ -FROM golang:1.21-bullseye AS kava-builder +FROM kava/rocksdb:v8.10.1-go1.21 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.10.0 -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 +RUN apt-get update WORKDIR /root/kava # Copy dependency files first to facilitate dependency caching diff --git a/Dockerfile-rocksdb-base b/Dockerfile-rocksdb-base new file mode 100644 index 00000000..30b3de26 --- /dev/null +++ b/Dockerfile-rocksdb-base @@ -0,0 +1,22 @@ +# published to https://hub.docker.com/repository/docker/kava/rocksdb/tags +# docker buildx build --platform linux/amd64,linux/arm64 -t kava/rocksdb:v8.10.1-go1.21 -f Dockerfile-rocksdb-base . --push +FROM golang:1.21-bullseye + +# 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.10.0 +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