17755: Merge branch 'main' into 17755-add-singularity-to-compute-image
[arvados.git] / tools / arvbox / lib / arvbox / docker / Dockerfile.base
1 # syntax = docker/dockerfile:experimental
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 ARG BUILDTYPE
7
8 # We're using poor man's conditionals (see
9 # https://www.docker.com/blog/advanced-dockerfiles-faster-builds-and-smaller-images-using-buildkit-and-multistage-builds/)
10 # here to dtrt in the dev/test scenario and the demo scenario. In the dev/test
11 # scenario, we use the docker context (i.e. the copy of Arvados checked out on
12 # the host) to build arvados-server. In the demo scenario, we check out a new
13 # tree, and use the $arvados_version commit (passed in via an argument).
14
15 ###########################################################################################################
16 FROM debian:10-slim as dev
17 ENV DEBIAN_FRONTEND noninteractive
18
19 RUN echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list
20
21 RUN apt-get update && \
22     apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
23     golang -t buster-backports
24
25 RUN apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
26     build-essential ca-certificates git libpam0g-dev
27
28 ENV GOPATH /var/lib/gopath
29
30 # the --mount option requires the experimental syntax enabled (enables
31 # buildkit) on the first line of this file. This Dockerfile must also be built
32 # with the DOCKER_BUILDKIT=1 environment variable set.
33 RUN --mount=type=bind,target=/usr/src/arvados \
34     cd /usr/src/arvados && \
35     go mod download && \
36     cd cmd/arvados-server && \
37     go install
38
39 ###########################################################################################################
40 FROM debian:10-slim as demo
41 ENV DEBIAN_FRONTEND noninteractive
42
43 RUN echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list
44
45 RUN apt-get update && \
46     apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
47     golang -t buster-backports
48
49 RUN apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
50     build-essential ca-certificates git libpam0g-dev
51
52 ENV GOPATH /var/lib/gopath
53
54 ARG arvados_version
55 RUN echo arvados_version is git commit $arvados_version
56
57 RUN cd /usr/src && \
58     git clone --no-checkout https://git.arvados.org/arvados.git && \
59     git -C arvados checkout ${arvados_version} && \
60     cd /usr/src/arvados && \
61     go mod download && \
62     cd cmd/arvados-server && \
63     go install
64
65 ###########################################################################################################
66 FROM ${BUILDTYPE} as base
67
68 ###########################################################################################################
69 FROM debian:10
70 ENV DEBIAN_FRONTEND noninteractive
71
72 # The arvbox-specific dependencies are
73 #  gnupg2 runit python3-pip python3-setuptools python3-yaml shellinabox netcat less
74 RUN apt-get update && \
75     apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
76     gnupg2 runit python3-pip python3-setuptools python3-yaml shellinabox netcat less && \
77     apt-get clean
78
79 ENV GOPATH /var/lib/gopath
80 RUN echo buildtype is $BUILDTYPE
81
82 RUN mkdir -p $GOPATH/bin/
83 COPY --from=base $GOPATH/bin/arvados-server $GOPATH/bin/arvados-server
84 RUN $GOPATH/bin/arvados-server --version
85 RUN $GOPATH/bin/arvados-server install -type test
86
87 RUN /etc/init.d/postgresql start && \
88     su postgres -c 'dropuser arvados' && \
89     su postgres -c 'createuser -s arvbox' && \
90     /etc/init.d/postgresql stop
91
92 ENV GEM_HOME /var/lib/arvados/lib/ruby/gems/2.5.0
93 ENV PATH $PATH:$GEM_HOME/bin
94
95 VOLUME /var/lib/docker
96 VOLUME /var/log/nginx
97 VOLUME /etc/ssl/private
98
99 ARG workdir
100
101 ADD $workdir/8D81803C0EBFCD88.asc /tmp/
102 RUN apt-key add --no-tty /tmp/8D81803C0EBFCD88.asc && \
103     rm -f /tmp/8D81803C0EBFCD88.asc
104
105 RUN mkdir -p /etc/apt/sources.list.d && \
106     echo deb https://download.docker.com/linux/debian/ buster stable > /etc/apt/sources.list.d/docker.list && \
107     apt-get update && \
108     apt-get -yq --no-install-recommends install docker-ce=5:19.03.13~3-0~debian-buster && \
109     apt-get clean
110
111 # Set UTF-8 locale
112 RUN echo en_US.UTF-8 UTF-8 > /etc/locale.gen && locale-gen
113 ENV LANG en_US.UTF-8
114 ENV LANGUAGE en_US:en
115 ENV LC_ALL en_US.UTF-8
116
117 ARG arvados_version
118 RUN echo arvados_version is git commit $arvados_version
119
120 COPY $workdir/fuse.conf /etc/
121
122 COPY $workdir/gitolite.rc \
123     $workdir/keep-setup.sh $workdir/common.sh $workdir/createusers.sh \
124     $workdir/logger $workdir/runsu.sh $workdir/waitforpostgres.sh \
125     $workdir/yml_override.py $workdir/api-setup.sh \
126     $workdir/go-setup.sh $workdir/devenv.sh $workdir/cluster-config.sh $workdir/edit_users.py \
127     /usr/local/lib/arvbox/
128
129 COPY $workdir/runit /etc/runit
130
131 # arvbox mounts a docker volume at $ARVADOS_CONTAINER_PATH, make sure that that
132 # doesn't overlap with the directory where `arvados-server install -type test`
133 # put everything (/var/lib/arvados)
134 ENV ARVADOS_CONTAINER_PATH /var/lib/arvados-arvbox
135
136 RUN /bin/ln -s /var/lib/arvados/bin/ruby /usr/local/bin/
137
138 # Start the supervisor.
139 ENV SVDIR /etc/service
140 STOPSIGNAL SIGINT
141 CMD ["/etc/runit/2"]