Merge branch '19830-pysdk-util-docs'
[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 # Install go
11 ONBUILD ARG GOVERSION
12 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
13 ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
14 # Install nodejs and npm
15 ONBUILD ADD generated/node-v12.22.12-linux-x64.tar.xz /usr/local/
16 ONBUILD RUN ln -s /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
17 ONBUILD RUN npm install -g yarn
18 ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
19 # On x86, we want some cross-compilation support for arm64
20 # Add gcc-aarch64-linux-gnu to compile go binaries for arm64
21 ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y gcc-aarch64-linux-gnu
22 # We also need libpam compiled for arm64, and that requires some sources.list mangling
23 ONBUILD RUN /bin/sed -i 's/deb http/deb [ arch=amd64 ] http/' /etc/apt/sources.list
24 ONBUILD ADD ports.list /etc/apt/sources.list.d/
25 ONBUILD RUN /usr/bin/dpkg --add-architecture arm64
26 ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -o APT::Immediate-Configure=0 -q -y libpam0g-dev:arm64
27 # Note that cross compilation support for ubuntu2004 is disabled in
28 # run-library.sh because of
29 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477. Hopefully
30 # ubuntu2204 will have the fix introduced in debian11.
31
32 FROM ubuntu:focal as build_aarch64
33 # Install go
34 ONBUILD ARG GOVERSION
35 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
36 ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
37 # Install nodejs and npm
38 ONBUILD ADD generated/node-v12.22.12-linux-arm64.tar.xz /usr/local/
39 ONBUILD RUN ln -s /usr/local/node-v12.22.12-linux-arm64/bin/* /usr/local/bin/
40 ONBUILD RUN npm install -g yarn
41 ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-arm64/bin/* /usr/local/bin/
42
43 FROM build_${HOSTTYPE}
44
45 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
46
47 ENV DEBIAN_FRONTEND noninteractive
48
49 SHELL ["/bin/bash", "-c"]
50 # Install dependencies.
51 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python3 python3-pip libcurl4-gnutls-dev libgnutls28-dev curl git libattr1-dev libfuse-dev libpq-dev unzip tzdata python3-venv python3-dev libpam-dev shared-mime-info equivs
52
53 # Install virtualenv
54 RUN /usr/bin/pip3 install 'virtualenv<20'
55
56 # Install RVM
57 ADD generated/mpapis.asc /tmp/
58 ADD generated/pkuczynski.asc /tmp/
59 RUN gpg --import --no-tty /tmp/mpapis.asc && \
60     gpg --import --no-tty /tmp/pkuczynski.asc && \
61     curl -L https://get.rvm.io | bash -s stable && \
62     /usr/local/rvm/bin/rvm install 2.7 -j $(grep -c processor /proc/cpuinfo) && \
63     /usr/local/rvm/bin/rvm alias create default ruby-2.7 && \
64     echo "gem: --no-document" >> ~/.gemrc && \
65     /usr/local/rvm/bin/rvm-exec default gem install bundler --version 2.2.19 && \
66     /usr/local/rvm/bin/rvm-exec default gem install fpm --version 1.10.2
67
68 RUN /usr/local/rvm/bin/rvm-exec default bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
69 # Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
70 ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
71
72 # Preseed the go module cache and the ruby gems, using the currently checked
73 # out branch of the source tree. This avoids potential compatibility issues
74 # between the version of Ruby and certain gems.
75 RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
76     cd /tmp/arvados && \
77     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
78     cd /tmp/arvados/services/api && \
79     /usr/local/rvm/bin/rvm-exec default bundle install && \
80     cd /tmp/arvados && \
81     go mod download
82
83 ENV WORKSPACE /arvados
84 CMD ["/usr/local/rvm/bin/rvm-exec", "default", "bash", "/jenkins/run-build-packages.sh", "--target", "ubuntu2004"]