1# Copyright 2022 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15FROM ubuntu:22.04
16
17# install system deps
18RUN apt-get update && apt-get install -y build-essential wget vim libstdc++-10-dev \
19clang git checkinstall zlib1g-dev curl protobuf-compiler cmake \
20pkg-config libdbus-1-dev ninja-build libssl-dev default-jre
21RUN apt upgrade -y
22
23RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
24RUN apt-get -y install ./google-chrome-stable_current_amd64.deb
25RUN export CHROME_BIN="/usr/bin/google-chrome-stable"
26
27ENV CC=/usr/bin/clang
28ENV CXX=/usr/bin/clang++
29
30# install cargo with default settings
31RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.77.1
32ENV PATH="/root/.cargo/bin:${PATH}"
33RUN rustup install stable
34RUN rustup toolchain install nightly --force
35RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
36RUN rustup target add wasm32-unknown-unknown thumbv7m-none-eabi
37
38RUN cargo install --locked cargo-deny --color never 2>&1
39RUN cargo install --locked cargo-llvm-cov --color never 2>&1
40RUN cargo install bindgen-cli --version 0.69.4 --color never 2>&1
41RUN cargo install wasm-pack --color never 2>&1
42
43# unreleased PR https://github.com/ehuss/cargo-prefetch/pull/6
44RUN cargo install cargo-prefetch \
45    --git https://github.com/marshallpierce/cargo-prefetch.git \
46    --rev f6affa68e950275f9fd773f2646ab7ee4db82897 \
47    --color never 2>&1
48
49# boringssl build wants go
50RUN curl -L https://go.dev/dl/go1.20.2.linux-amd64.tar.gz | tar -C /usr/local -xz
51ENV PATH="$PATH:/usr/local/go/bin"
52
53# needed for boringssl git operations
54RUN git config --global user.email "[email protected]"
55RUN git config --global user.name "NP Docker"
56
57# Download google-java-format
58RUN mkdir /opt/google-java-format
59WORKDIR /opt/google-java-format
60ENV GOOGLE_JAVA_FORMAT_VERSION="1.19.2"
61RUN wget "https://github.com/google/google-java-format/releases/download/v${GOOGLE_JAVA_FORMAT_VERSION}/google-java-format-${GOOGLE_JAVA_FORMAT_VERSION}-all-deps.jar" -q -O "google-java-format-all-deps.jar"
62
63RUN mkdir -p /beto-core
64COPY . /beto-core
65WORKDIR /beto-core
66
67# prefetch dependencies so later build steps don't re-download on source changes
68RUN cargo prefetch --lockfile nearby/Cargo.lock 2>&1
69RUN cargo prefetch --lockfile common/Cargo.lock 2>&1
70
71# when the image runs build and test everything to ensure env is setup correctly
72WORKDIR /beto-core/nearby
73CMD ["cargo", "run", "--", "check-everything"]
74