21700: Install Bundler system-wide in Rails postinst
[arvados.git] / build / package-build-dockerfiles / ubuntu2004 / Dockerfile
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 ARG HOSTTYPE
6 ARG BRANCH
7 ARG GOVERSION
8
9 FROM ubuntu:focal as build_x86_64
10 ONBUILD ARG BRANCH
11 # Install go
12 ONBUILD ARG GOVERSION
13 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
14 ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
15 # Install nodejs and npm
16 ONBUILD ADD generated/node-v12.22.12-linux-x64.tar.xz /usr/local/
17 ONBUILD RUN ln -s /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
18 ONBUILD RUN npm install -g yarn
19 ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
20 # On x86, we want some cross-compilation support for arm64
21 # Add gcc-aarch64-linux-gnu to compile go binaries for arm64
22 ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y gcc-aarch64-linux-gnu
23 # We also need libpam compiled for arm64, and that requires some sources.list mangling
24 ONBUILD RUN /bin/sed -i 's/deb http/deb [ arch=amd64 ] http/' /etc/apt/sources.list
25 ONBUILD ADD ports.list /etc/apt/sources.list.d/
26 ONBUILD RUN /usr/bin/dpkg --add-architecture arm64
27 ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -o APT::Immediate-Configure=0 -q -y libpam0g-dev:arm64
28 # Note that cross compilation support for ubuntu2004 is disabled in
29 # run-library.sh because of
30 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477. Hopefully
31 # ubuntu2204 will have the fix introduced in debian11.
32
33 FROM ubuntu:focal as build_aarch64
34 ONBUILD ARG BRANCH
35 # Install go
36 ONBUILD ARG GOVERSION
37 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
38 ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
39 # Install nodejs and npm
40 ONBUILD ADD generated/node-v12.22.12-linux-arm64.tar.xz /usr/local/
41 ONBUILD RUN ln -s /usr/local/node-v12.22.12-linux-arm64/bin/* /usr/local/bin/
42 ONBUILD RUN npm install -g yarn
43 ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-arm64/bin/* /usr/local/bin/
44
45 FROM build_${HOSTTYPE}
46
47 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
48
49 ENV DEBIAN_FRONTEND noninteractive
50
51 SHELL ["/bin/bash", "-c"]
52 # Install dependencies.
53 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y \
54     build-essential \
55     curl \
56     equivs \
57     git \
58     libattr1-dev \
59     libcurl4-gnutls-dev \
60     libfuse-dev \
61     libgnutls28-dev \
62     libpam-dev \
63     libpq-dev \
64     pkgconf \
65     python3 \
66     python3-dev \
67     python3-venv \
68     ruby \
69     ruby-dev \
70     shared-mime-info \
71     tzdata \
72     unzip
73
74 # fpm depends on dotenv, but version 3.0 of that gem dropped support for
75 # Ruby 2.7, so we need to specifically install an older version.
76 RUN echo "gem: --no-document" >> ~/.gemrc && \
77     gem install --conservative --version '~> 2.4.0' bundler && \
78     gem install dotenv --version '~> 2.8' && \
79     gem install fpm --version 1.15.1 && \
80     bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
81
82 # Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
83 ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
84
85 # Preseed the go module cache.
86 RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
87     cd /tmp/arvados && \
88     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
89     go mod download
90
91 ENV WORKSPACE /arvados
92 CMD ["bash", "/jenkins/run-build-packages.sh", "--target", "ubuntu2004"]