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