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