github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/build/builder/Dockerfile (about) 1 FROM ubuntu:xenial-20170915 2 3 # This is the CockroachDB "builder" image, which bundles cross-compiling 4 # toolchains that can build CockroachDB on all supported platforms. 5 6 # WARNING: Rebuilding this image can take several hours. Keep the slower steps 7 # (specifically, the compilation of the release toolchains) near the top to 8 # minimize how often they need to be rebuilt. 9 10 # autoconf - crosstool-ng / c-deps: jemalloc 11 # bison - crosstool-ng 12 # bzip2 - crosstool-ng 13 # file - crosstool-ng 14 # flex - crosstool-ng 15 # g++ - crosstool-ng 16 # gawk - crosstool-ng 17 # git - crosstool-ng 18 # gperf - crosstool-ng 19 # help2man - crosstool-ng 20 # libncurses-dev - crosstool-ng / CRDB build system 21 # make - crosstool-ng / CRDB build system 22 # patch - crosstool-ng 23 # texinfo - crosstool-ng 24 # xz-utils - crosstool-ng / msan 25 RUN apt-get update && apt-get install -y --no-install-recommends \ 26 apt-transport-https \ 27 autoconf \ 28 bison \ 29 bzip2 \ 30 ca-certificates \ 31 curl \ 32 file \ 33 flex \ 34 g++ \ 35 gawk \ 36 git \ 37 gperf \ 38 help2man \ 39 libncurses-dev \ 40 make \ 41 patch \ 42 texinfo \ 43 xz-utils \ 44 && apt-get clean 45 46 RUN mkdir crosstool-ng \ 47 && curl -fsSL http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.23.0.tar.xz | tar --strip-components=1 -C crosstool-ng -xJ \ 48 && cd crosstool-ng \ 49 && ./configure --prefix /usr/local/ct-ng \ 50 && make -j$(nproc) \ 51 && make install \ 52 && cp ct-ng.comp /etc/bash_completion.d/ \ 53 && cd .. \ 54 && rm -rf crosstool-ng 55 56 COPY x86_64-unknown-linux-gnu.defconfig x86_64-w64-mingw.defconfig aarch64-unknown-linux-gnueabi.defconfig ./ 57 RUN mkdir src \ 58 && mkdir build && (cd build && DEFCONFIG=../x86_64-unknown-linux-gnu.defconfig /usr/local/ct-ng/bin/ct-ng defconfig && /usr/local/ct-ng/bin/ct-ng build) && rm -rf build \ 59 && mkdir build && (cd build && DEFCONFIG=../x86_64-w64-mingw.defconfig /usr/local/ct-ng/bin/ct-ng defconfig && /usr/local/ct-ng/bin/ct-ng build) && rm -rf build \ 60 && mkdir build && (cd build && DEFCONFIG=../aarch64-unknown-linux-gnueabi.defconfig /usr/local/ct-ng/bin/ct-ng defconfig && /usr/local/ct-ng/bin/ct-ng build) && rm -rf build \ 61 && rm -rf src 62 63 RUN mkdir -p /usr/local/lib/ccache \ 64 && ln -s /usr/bin/ccache /usr/local/lib/ccache/x86_64-unknown-linux-gnu-cc \ 65 && ln -s /usr/bin/ccache /usr/local/lib/ccache/x86_64-unknown-linux-gnu-c++ \ 66 && ln -s /usr/bin/ccache /usr/local/lib/ccache/x86_64-w64-mingw32-cc \ 67 && ln -s /usr/bin/ccache /usr/local/lib/ccache/x86_64-w64-mingw32-c++ \ 68 && ln -s /usr/bin/ccache /usr/local/lib/ccache/aarch64-unknown-linux-gnueabi-cc \ 69 && ln -s /usr/bin/ccache /usr/local/lib/ccache/aarch64-unknown-linux-gnueabi-c++ 70 71 ENV PATH $PATH:/x-tools/x86_64-unknown-linux-gnu/bin:/x-tools/x86_64-w64-mingw32/bin:/x-tools/aarch64-unknown-linux-gnueabi/bin 72 73 # Build & install the terminfo lib (incl. in ncurses) for the linux targets (x86 and arm). 74 # (on BSD or BSD-derived like macOS it's already built-in; on windows we don't need it.) 75 # 76 # The patch is needed to work around a bug in Debian mawk, see 77 # http://lists.gnu.org/archive/html/bug-ncurses/2015-08/msg00008.html 78 COPY ncurses.patch ./ 79 # 80 # Run the three builds. 81 # As per the Debian rule file for ncurses, the two configure tests for 82 # the type of bool and poll(2) are broken when cross-compiling, so we 83 # need to feed the test results manually to configure via an environment 84 # variable; see debian/rules on the Debian ncurses source package. 85 # 86 # The configure other settings in ncurses.conf are also sourced from the 87 # Debian source package. 88 # 89 COPY ncurses.conf ./ 90 RUN mkdir ncurses \ 91 && curl -fsSL http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz | tar --strip-components=1 -C ncurses -xz \ 92 && cd ncurses \ 93 && patch -p0 <../ncurses.patch \ 94 && export cf_cv_type_of_bool='unsigned char' \ 95 && export cf_cv_working_poll=yes \ 96 && mkdir build-x86_64-unknown-linux-gnu \ 97 && (cd build-x86_64-unknown-linux-gnu \ 98 && CC=/x-tools/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-cc \ 99 CXX=/x-tools/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-c++ \ 100 ../configure --prefix=/x-tools/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr \ 101 --host=x86_64-unknown-linux-gnu \ 102 $(cat /ncurses.conf) \ 103 && make install.libs) \ 104 && mkdir build-aarch64-unknown-linux-gnueabi \ 105 && (cd build-aarch64-unknown-linux-gnueabi \ 106 && CC=/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-cc \ 107 CXX=/x-tools/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-c++ \ 108 ../configure --prefix=/x-tools/aarch64-unknown-linux-gnueabi/aarch64-unknown-linux-gnueabi/sysroot/usr \ 109 --host=aarch64-unknown-linux-gnueabi \ 110 $(cat /ncurses.conf) \ 111 && make install.libs) \ 112 && cd .. \ 113 && rm -rf ncurses ncurses.conf ncurses.patch 114 115 RUN apt-get purge -y gcc g++ && apt-get autoremove -y 116 117 # clang - msan 118 # cmake - msan / c-deps: libroach, protobuf, et al. 119 # python - msan 120 RUN apt-get update && apt-get install -y --no-install-recommends \ 121 clang \ 122 cmake \ 123 python 124 125 # Build an msan-enabled build of libc++, following instructions from 126 # https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo 127 RUN mkdir llvm && curl -sfSL http://releases.llvm.org/3.9.1/llvm-3.9.1.src.tar.xz | tar --strip-components=1 -C llvm -xJ \ 128 && mkdir llvm/projects/libcxx && curl -sfSL http://releases.llvm.org/3.9.1/libcxx-3.9.1.src.tar.xz | tar --strip-components=1 -C llvm/projects/libcxx -xJ \ 129 && mkdir llvm/projects/libcxxabi && curl -sfSL http://releases.llvm.org/3.9.1/libcxxabi-3.9.1.src.tar.xz | tar --strip-components=1 -C llvm/projects/libcxxabi -xJ \ 130 && curl -fsSL https://github.com/llvm-mirror/libcxx/commit/b640da0b315ead39690d4d65c76938ab8aeb5449.patch | git -C llvm/projects/libcxx apply \ 131 && mkdir libcxx_msan && (cd libcxx_msan && cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_SANITIZER=Memory && make cxx -j$(nproc)) \ 132 && rm -rf llvm 133 134 # Install osxcross. This needs the min supported osx version (we bump that 135 # whenever Go does, in which case the builder image stops working). The SDK 136 # can either be generated from Xcode or we let someone else do the work. 137 # See for example: 138 # https://github.com/docker/golang-cross/pull/11#issuecomment-428741406. 139 # 140 # See https://en.wikipedia.org/wiki/Uname for the right suffix in the `mv` step 141 # below. For example, Yosemite is 10.10 and has kernel release (uname -r) 142 # 14.0.0. Similar edits are needed in mkrelease.sh. 143 # 144 # The osxcross SHA should be bumped. It's fixed merely to avoid an obvious 145 # highjack of the upstream repo from slipping in unnoticed. 146 RUN git clone https://github.com/tpoechtrager/osxcross.git \ 147 && (cd osxcross && git checkout 6525b2b7d33abc371ad889f205377dc5cf81f23e) \ 148 && (cd osxcross/tarballs && curl -sfSL https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz -O) \ 149 && echo "631b4144c6bf75bf7a4d480d685a9b5bda10ee8d03dbf0db829391e2ef858789 osxcross/tarballs/MacOSX10.10.sdk.tar.xz" | sha256sum -c - \ 150 && OSX_VERSION_MIN=10.10 PORTABLE=1 UNATTENDED=1 osxcross/build.sh \ 151 && mv osxcross/target /x-tools/x86_64-apple-darwin14 \ 152 && rm -rf osxcross 153 154 RUN ln -s /usr/bin/ccache /usr/local/lib/ccache/x86_64-apple-darwin14-cc \ 155 && ln -s /usr/bin/ccache /usr/local/lib/ccache/x86_64-apple-darwin14-c++ 156 157 ENV PATH $PATH:/x-tools/x86_64-apple-darwin14/bin 158 159 # automake - sed build 160 # autopoint - sed build 161 # gettext - sed build 162 # rsync - sed build 163 RUN apt-get update && apt-get install -y --no-install-recommends \ 164 automake \ 165 autopoint \ 166 gettext \ 167 rsync 168 169 # Compile GNU sed from source to pick up an unreleased change that buffers 170 # output. This speeds up compiles on Docker for Mac by *minutes*. 171 RUN git clone git://git.sv.gnu.org/sed \ 172 && cd sed \ 173 && git checkout 8e52c0aff039f0a88127ca131b060050c107b0e2 \ 174 && ./bootstrap \ 175 && ./configure \ 176 && make \ 177 && make install \ 178 && cd .. \ 179 && rm -rf sed 180 181 # xenial installs cmake 3.5.1. We need a newer version. Run this step 182 # after the llvm/cross-compile step which is exceedingly slow. 183 # 184 # NOTE: When upgrading cmake, bump the rebuild counters in 185 # c-deps/*-rebuild to force recreating the makefiles. This prevents 186 # strange build errors caused by those makefiles depending on the 187 # installed version of cmake. 188 RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.tar.gz -o cmake.tar.gz \ 189 && echo 'b44685227b9f9be103e305efa2075a8ccf2415807fbcf1fc192da4d36aacc9f5 cmake.tar.gz' | sha256sum -c - \ 190 && tar --strip-components=1 -C /usr -xzf cmake.tar.gz \ 191 && rm cmake.tar.gz 192 193 # Compile Go from source so that CC defaults to clang instead of gcc. This 194 # requires a Go toolchain to bootstrap. 195 # 196 # NB: care needs to be taken when updating this version because earlier 197 # releases of Go will no longer be run in CI once it is changed. Consider 198 # bumping the minimum allowed version of Go in /build/go-version-chech.sh. 199 RUN apt-get install -y --no-install-recommends golang \ 200 && curl -fsSL https://storage.googleapis.com/golang/go1.13.9.src.tar.gz -o golang.tar.gz \ 201 && echo '34bb19d806e0bc4ad8f508ae24bade5e9fedfa53d09be63b488a9314d2d4f31d golang.tar.gz' | sha256sum -c - \ 202 && tar -C /usr/local -xzf golang.tar.gz \ 203 && rm golang.tar.gz \ 204 && cd /usr/local/go/src \ 205 && GOROOT_BOOTSTRAP=$(go env GOROOT) CC=clang CXX=clang++ ./make.bash 206 207 ENV GOPATH /go 208 ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH 209 210 RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" 211 WORKDIR $GOPATH 212 213 RUN chmod -R a+w $(go env GOTOOLDIR) 214 215 # Allow Go support files in gdb. 216 RUN echo "add-auto-load-safe-path $(go env GOROOT)/src/runtime/runtime-gdb.py" > ~/.gdbinit 217 218 RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \ 219 && echo 'deb https://deb.nodesource.com/node_12.x xenial main' | tee /etc/apt/sources.list.d/nodesource.list \ 220 && curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ 221 && echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list \ 222 && curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \ 223 && echo 'deb https://packages.cloud.google.com/apt cloud-sdk-xenial main' | tee /etc/apt/sources.list.d/gcloud.list \ 224 && curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ 225 && echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google.list \ 226 && apt-get update 227 228 # ccache - speed up C and C++ compilation 229 # lsof - roachprod monitor 230 # netcat - roachprod monitor 231 # netbase - /etc/services etc 232 # nodejs - ui 233 # openjdk-8-jre - railroad diagram generation 234 # google-cloud-sdk - roachprod acceptance tests 235 # yarn - ui 236 # chrome - ui 237 # unzip - for installing awscli 238 RUN apt-get install -y --no-install-recommends \ 239 ccache \ 240 google-cloud-sdk \ 241 lsof \ 242 netcat \ 243 netbase \ 244 nodejs \ 245 openjdk-8-jre \ 246 openssh-client \ 247 yarn \ 248 google-chrome-stable \ 249 unzip 250 251 # awscli - roachtests 252 # NB: we don't use apt-get because we need an up to date version of awscli 253 RUN curl -fsSL "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" && \ 254 unzip awscli-bundle.zip && \ 255 ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \ 256 rm -rf awscli-bundle.zip awscli-bundle 257 258 # git - Upgrade to a more modern version 259 RUN apt-get install -y python-software-properties software-properties-common && \ 260 add-apt-repository ppa:git-core/ppa -y && \ 261 apt-get update && \ 262 apt-get install -y git 263 264 ENV PATH /opt/backtrace/bin:$PATH 265 266 RUN apt-get purge -y \ 267 apt-transport-https \ 268 automake \ 269 autopoint \ 270 bzip2 \ 271 file \ 272 flex \ 273 gawk \ 274 gettext \ 275 golang \ 276 gperf \ 277 help2man \ 278 python \ 279 rsync \ 280 texinfo \ 281 && apt-get autoremove -y 282 283 RUN rm -rf /tmp/* /var/lib/apt/lists/* 284 285 RUN ln -s /go/src/github.com/cockroachdb/cockroach/build/builder/mkrelease.sh /usr/local/bin/mkrelease 286 287 RUN curl -fsSL https://github.com/benesch/autouseradd/releases/download/1.1.0/autouseradd-1.1.0-amd64.tar.gz \ 288 | tar xz -C /usr --strip-components 1 289 290 COPY entrypoint.sh /usr/local/bin 291 292 ENTRYPOINT ["autouseradd", "--user", "roach", "--no-create-home", "--", "entrypoint.sh"]