|
| 1 | +# This Docker image contains a minimal build environment for TiKV |
| 2 | +# |
| 3 | +# It contains all the tools necessary to reproduce official production builds of TiKV |
| 4 | + |
| 5 | +# We need to use CentOS 7 because many of our users choose this as their deploy machine. |
| 6 | +# Since the glibc it uses (2.17) is from 2012 (https://sourceware.org/glibc/wiki/Glibc%20Timeline) |
| 7 | +# it is our lowest common denominator in terms of distro support. |
| 8 | + |
| 9 | +# Some commands in this script are structured in order to reduce the number of layers Docker |
| 10 | +# generates. Unfortunately Docker is limited to only 125 layers: |
| 11 | +# https://github.com/moby/moby/blob/a9507c6f76627fdc092edc542d5a7ef4a6df5eec/layer/layer.go#L50-L53 |
| 12 | + |
| 13 | +# We require epel packages, so enable the fedora EPEL repo then install dependencies. |
| 14 | +# Install the system dependencies |
| 15 | +# Attempt to clean and rebuild the cache to avoid 404s |
| 16 | + |
| 17 | +# To avoid rebuilds we first install all Cargo dependencies |
| 18 | + |
| 19 | + |
| 20 | +# The prepare image avoid ruining the cache of the builder |
| 21 | +FROM centos:7.6.1810 as builder |
| 22 | + |
| 23 | +RUN yum install -y epel-release && \ |
| 24 | + yum clean all && \ |
| 25 | + yum makecache |
| 26 | + |
| 27 | +RUN yum install -y centos-release-scl && \ |
| 28 | + yum install -y \ |
| 29 | + devtoolset-8 \ |
| 30 | + perl cmake3 && \ |
| 31 | + yum clean all |
| 32 | + |
| 33 | +# CentOS gives cmake 3 a weird binary name, so we link it to something more normal |
| 34 | +# This is required by many build scripts, including ours. |
| 35 | +RUN ln -s /usr/bin/cmake3 /usr/bin/cmake |
| 36 | +ENV LIBRARY_PATH /usr/local/lib:$LIBRARY_PATH |
| 37 | +ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH |
| 38 | + |
| 39 | +# Install protoc |
| 40 | +RUN curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip" |
| 41 | +RUN unzip protoc-3.15.8-linux-x86_64.zip -d /usr/local/ |
| 42 | +ENV PATH /usr/local/bin/:$PATH |
| 43 | + |
| 44 | +# Install Rustup |
| 45 | +RUN curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path --default-toolchain none -y |
| 46 | +ENV PATH /root/.cargo/bin/:$PATH |
| 47 | + |
| 48 | +# Install the Rust toolchain |
| 49 | +WORKDIR /tikv |
| 50 | +COPY rust-toolchain ./ |
| 51 | +RUN rustup self update \ |
| 52 | + && rustup set profile minimal \ |
| 53 | + && rustup default $(cat "rust-toolchain") |
| 54 | + |
| 55 | +RUN cargo install cargo-nextest --locked |
| 56 | + |
| 57 | +ENTRYPOINT ["sh", "-c", "source /opt/rh/devtoolset-8/enable && \"$@\"", "-s"] |
0 commit comments