From 8cdcb5e9c2d4385c220976412d8bcef4d2818ff6 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Mon, 6 Nov 2023 10:01:47 -0700 Subject: [PATCH] Add support for rocksdb and pebbledb --- Dockerfile | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ab9d030..78e3f232 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,22 @@ RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \ wget -c https://musl.cc/x86_64-linux-musl-cross.tgz -O - | tar -xzvv --strip-components 1 -C /usr; \ fi +# Install RocksDB +WORKDIR / +RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >>/etc/apk/repositories + +RUN apk add --update --no-cache git make cmake g++ linux-headers build-base bash perl mercurial g++ autoconf \ + zlib zlib-dev bzip2 bzip2-dev snappy snappy-dev lz4 lz4-dev zstd@testing zstd-dev@testing libtbb-dev@testing libtbb@testing +RUN git clone -b v7.10.2 --single-branch https://github.com/facebook/rocksdb.git + +WORKDIR /rocksdb +RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \ + export CC=aarch64-linux-musl-gcc CXX=aarch64-linux-musl-g++;\ + elif [ "${TARGETARCH}" = "amd64" ] && [ "${BUILDARCH}" != "amd64" ]; then \ + export CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++; \ + fi; \ + make -j$(nproc) static_lib + WORKDIR /workspace # Copy the Go Modules manifests COPY go.mod go.mod @@ -28,13 +44,16 @@ COPY internal/ internal/ ARG VERSION -RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \ +RUN set -eux;\ + if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then\ export CC=aarch64-linux-musl-gcc CXX=aarch64-linux-musl-g++;\ - elif [ "${TARGETARCH}" = "amd64" ] && [ "${BUILDARCH}" != "amd64" ]; then \ - export CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++; \ - fi; \ - export GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"'; \ - go build -ldflags "-X github.com/strangelove-ventures/cosmos-operator/internal/version.version=$VERSION $LDFLAGS" -a -o manager . + elif [ "${TARGETARCH}" = "amd64" ] && [ "${BUILDARCH}" != "amd64" ]; then\ + export CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++;\ + fi;\ + export GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\ + export LD_LIBRARY_PATH=/rocksdb CGO_CFLAGS="-I/rocksdb/include" CGO_LDFLAGS="-L/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd";\ + go get github.com/tecbot/gorocksdb;\ + go build -tags 'rocksdb pebbledb' -ldflags "-X github.com/strangelove-ventures/cosmos-operator/internal/version.version=$VERSION $LDFLAGS" -a -o manager . # Build final image from scratch FROM scratch