Merge branch '18273-java-timeout' refs #18273
[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 apt-get update && \
20     apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
21     build-essential ca-certificates git libpam0g-dev wget
22
23 ENV GOPATH /var/lib/gopath
24
25 # Get Go 1.16.9
26 RUN cd /usr/src && \
27     wget https://golang.org/dl/go1.16.9.linux-amd64.tar.gz && \
28     tar xzf go1.16.9.linux-amd64.tar.gz && \
29     ln -s /usr/src/go/bin/go /usr/local/bin/go-1.16.9 && \
30     ln -s /usr/src/go/bin/gofmt /usr/local/bin/gofmt-1.16.9 && \
31     ln -s /usr/local/bin/go-1.16.9 /usr/local/bin/go && \
32     ln -s /usr/local/bin/gofmt-1.16.9 /usr/local/bin/gofmt
33
34 # the --mount option requires the experimental syntax enabled (enables
35 # buildkit) on the first line of this file. This Dockerfile must also be built
36 # with the DOCKER_BUILDKIT=1 environment variable set.
37 RUN --mount=type=bind,target=/usr/src/arvados \
38     cd /usr/src/arvados && \
39     go mod download && \
40     cd cmd/arvados-server && \
41     go install
42
43 ###########################################################################################################
44 FROM debian:10-slim as demo
45 ENV DEBIAN_FRONTEND noninteractive
46
47 RUN apt-get update && \
48     apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
49     build-essential ca-certificates git libpam0g-dev wget
50
51 ENV GOPATH /var/lib/gopath
52
53 # Get Go 1.16.9
54 RUN cd /usr/src && \
55     wget https://golang.org/dl/go1.16.9.linux-amd64.tar.gz && \
56     tar xzf go1.16.9.linux-amd64.tar.gz && \
57     ln -s /usr/src/go/bin/go /usr/local/bin/go-1.16.9 && \
58     ln -s /usr/src/go/bin/gofmt /usr/local/bin/gofmt-1.16.9 && \
59     ln -s /usr/local/bin/go-1.16.9 /usr/local/bin/go && \
60     ln -s /usr/local/bin/gofmt-1.16.9 /usr/local/bin/gofmt
61
62 ARG arvados_version
63 RUN echo arvados_version is git commit $arvados_version
64
65 RUN cd /usr/src && \
66     git clone --no-checkout https://git.arvados.org/arvados.git && \
67     git -C arvados checkout ${arvados_version} && \
68     cd /usr/src/arvados && \
69     go mod download && \
70     cd cmd/arvados-server && \
71     go install
72
73 ###########################################################################################################
74 FROM ${BUILDTYPE} as base
75
76 ###########################################################################################################
77 FROM debian:10
78 ENV DEBIAN_FRONTEND noninteractive
79
80 # The arvbox-specific dependencies are
81 #  gnupg2 runit python3-pip python3-setuptools python3-yaml shellinabox netcat less
82 RUN apt-get update && \
83     apt-get -yq --no-install-recommends -o Acquire::Retries=6 install \
84     gnupg2 runit python3-pip python3-setuptools python3-yaml shellinabox netcat less vim-tiny && \
85     apt-get clean
86
87 ENV GOPATH /var/lib/gopath
88 RUN echo buildtype is $BUILDTYPE
89
90 RUN mkdir -p $GOPATH/bin/
91 COPY --from=base $GOPATH/bin/arvados-server $GOPATH/bin/arvados-server
92 RUN $GOPATH/bin/arvados-server --version
93 RUN $GOPATH/bin/arvados-server install -type test
94
95 RUN /etc/init.d/postgresql start && \
96     su postgres -c 'dropuser arvados' && \
97     su postgres -c 'createuser -s arvbox' && \
98     /etc/init.d/postgresql stop
99
100 ENV GEM_HOME /var/lib/arvados/lib/ruby/gems/2.5.0
101 ENV PATH $PATH:$GEM_HOME/bin
102
103 VOLUME /var/lib/docker
104 VOLUME /var/log/nginx
105 VOLUME /etc/ssl/private
106
107 ARG workdir
108
109 ADD $workdir/8D81803C0EBFCD88.asc /tmp/
110 RUN apt-key add --no-tty /tmp/8D81803C0EBFCD88.asc && \
111     rm -f /tmp/8D81803C0EBFCD88.asc
112
113 RUN mkdir -p /etc/apt/sources.list.d && \
114     echo deb https://download.docker.com/linux/debian/ buster stable > /etc/apt/sources.list.d/docker.list && \
115     apt-get update && \
116     apt-get -yq --no-install-recommends install docker-ce=5:20.10.6~3-0~debian-buster && \
117     apt-get clean
118
119 # Set UTF-8 locale
120 RUN echo en_US.UTF-8 UTF-8 > /etc/locale.gen && locale-gen
121 ENV LANG en_US.UTF-8
122 ENV LANGUAGE en_US:en
123 ENV LC_ALL en_US.UTF-8
124
125 ARG arvados_version
126 RUN echo arvados_version is git commit $arvados_version
127
128 COPY $workdir/fuse.conf /etc/
129
130 COPY $workdir/gitolite.rc \
131     $workdir/keep-setup.sh $workdir/common.sh $workdir/createusers.sh \
132     $workdir/logger $workdir/runsu.sh $workdir/waitforpostgres.sh \
133     $workdir/yml_override.py $workdir/api-setup.sh \
134     $workdir/go-setup.sh $workdir/devenv.sh $workdir/cluster-config.sh $workdir/edit_users.py \
135     /usr/local/lib/arvbox/
136
137 COPY $workdir/runit /etc/runit
138
139 # arvbox mounts a docker volume at $ARVADOS_CONTAINER_PATH, make sure that that
140 # doesn't overlap with the directory where `arvados-server install -type test`
141 # put everything (/var/lib/arvados)
142 ENV ARVADOS_CONTAINER_PATH /var/lib/arvados-arvbox
143
144 RUN /bin/ln -s /var/lib/arvados/bin/ruby /usr/local/bin/
145
146 # Start the supervisor.
147 ENV SVDIR /etc/service
148 STOPSIGNAL SIGINT
149 CMD ["/etc/runit/2"]