Skip to content

Commit abb1e46

Browse files
authored
Unify Android and standard Docker image (#3331)
Everything now works on JDK11, so a single image allows us to run all builds and tests at the same time, which will be useful as we continue working on the Java client. Fix #3336
1 parent 02aac9f commit abb1e46

File tree

16 files changed

+190
-622
lines changed

16 files changed

+190
-622
lines changed

.devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
// - https://code.visualstudio.com/docs/remote/devcontainerjson-reference
55
{
66
// Do not modify manually. This value is automatically updated by ./scripts/docker_build .
7-
// "image": "sha256:9a8c29fff8aabccb5be1f7f1117ebf76d4e1d9d05ffc6a9d3db559a8bd40e91d",
8-
"image": "europe-west2-docker.pkg.dev/oak-ci/oak-development/oak-development@sha256:4a458d8469a002cc685f1009df0833794b2964ab5cae539445845205304e4be3",
7+
"image": "sha256:1e05637c2f2519bad5e79f9c21972fe390ec40fa7e6aa746b61b34cdb0d82fa0",
98
"extensions": [
109
"13xforever.language-x86-64-assembly",
1110
"bazelbuild.vscode-bazel",

.github/workflows/ci.yaml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -113,32 +113,3 @@ jobs:
113113
# relevant build artifacts are ignored by git.
114114
- name: Git check diff
115115
run: ./scripts/docker_run ./scripts/git_check_diff
116-
117-
android-runner:
118-
runs-on: ubuntu-20.04
119-
strategy:
120-
fail-fast: false
121-
steps:
122-
- name: Checkout branch
123-
uses: actions/checkout@v3
124-
125-
# Copied from https://github.com/jens-maus/RaspberryMatic/blob/ea6b8ce0dd2d53ea88b2766ba8d7f8e1d667281f/.github/workflows/ci.yml#L34-L40
126-
# and https://github.com/actions/virtual-environments/issues/709#issuecomment-612569242
127-
- name: Free disk space
128-
run: |
129-
df --human-readable
130-
sudo apt clean
131-
docker rmi $(docker image ls --all --quiet)
132-
rm --recursive --force "$AGENT_TOOLSDIRECTORY"
133-
df --human-readable
134-
135-
# Build Docker image based for Android SDK.
136-
- name: Android Docker build
137-
timeout-minutes: 30
138-
run: |
139-
docker pull gcr.io/oak-ci/oak-android:latest
140-
./scripts/android_docker_build
141-
142-
# Build Android-based examples.
143-
- name: Build Android Hello-World
144-
run: ./scripts/android_docker_run ./scripts/build_examples_android

.hadolint.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ ignored:
22
# Pin versions in apt get install.
33
# See https://github.com/hadolint/hadolint/wiki/DL3008.
44
- DL3008
5-
# Set the SHELL option -o pipefail before RUN with a pipe in.
6-
# This does not seem to work well with android.Dockerfile.
7-
# See https://github.com/hadolint/hadolint/wiki/DL4006.
8-
- DL4006
5+
# Leave apt-get lists alone.
6+
- DL3009
97
# Ignore merging of multiple RUNs.
108
# We want to define the layout of our Dockerfiles.
119
- DL3059

Dockerfile

Lines changed: 88 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1414
# deb [arch=amd64] http://ukdebian.mirror.anlx.net/debian buster main non-free contrib\
1515
# > /etc/apt/sources.list
1616

17+
# First install the minimal set of utils that will be used to setup the rest of the packages to install.
18+
RUN apt-get --yes update && apt-get install --no-install-recommends --yes curl gnupg2 gnupg-agent ca-certificates
19+
20+
# Install LLDB for debugging support.
21+
ARG llvm_version=14
22+
RUN curl --fail --silent --show-error --location https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
23+
RUN echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-$llvm_version main" >> /etc/apt/sources.list.d/llvm.list
24+
25+
# Install docker CLI.
26+
RUN curl --fail --silent --show-error --location https://download.docker.com/linux/debian/gpg | apt-key add -
27+
RUN echo "deb [arch=amd64] https://download.docker.com/linux/debian bullseye stable" > /etc/apt/sources.list.d/backports.list
28+
29+
# Install NodeJS
30+
# https://github.com/nodesource/distributions/blob/master/README.md#manual-installation
31+
RUN curl --fail --silent --show-error --location https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
32+
RUN echo "deb https://deb.nodesource.com/node_18.x bullseye main" > /etc/apt/sources.list.d/nodesource.list
33+
1734
# Getting curl and certificates dependecies.
1835
# We're rate-limiting HTTP requests to 500 kB/s as otherwise we may get timeout errors
1936
# when downloading from snapshot.debian.org.
@@ -22,17 +39,25 @@ RUN apt-get --yes update \
2239
apt-transport-https \
2340
build-essential \
2441
ca-certificates \
42+
# `chromium` is required to run our tests with wasm-pack.
43+
chromium \
44+
chromium-driver \
2545
clang-format \
2646
clang-tidy \
47+
# `cmake` is needed for flatbuffer.
48+
cmake \
2749
curl \
50+
docker-ce-cli \
2851
git \
2952
gnupg2 \
3053
gnupg-agent \
3154
libcap-dev \
3255
libfl2 \
3356
libncurses5 \
3457
libssl-dev \
58+
lldb-${llvm_version} \
3559
musl-tools \
60+
nodejs \
3661
openjdk-11-jdk \
3762
pkg-config \
3863
procps \
@@ -54,23 +79,6 @@ RUN apt-get --yes update \
5479
&& git --version \
5580
&& shellcheck --version
5681

57-
# Add LLDB version 14 for debugging support.
58-
ARG llvm_version=14
59-
RUN echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-$llvm_version main" >> /etc/apt/sources.list.d/llvm.list \
60-
&& curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
61-
&& apt-get update --yes \
62-
&& apt-get install --no-install-recommends --yes \
63-
lldb-${llvm_version} \
64-
&& rm --recursive --force /var/lib/apt/lists/*
65-
66-
# Install a version of docker CLI.
67-
RUN curl --fail --silent --show-error --location https://download.docker.com/linux/debian/gpg | apt-key add -
68-
RUN echo "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" > /etc/apt/sources.list.d/backports.list \
69-
&& apt-get --yes update \
70-
&& apt-get install --no-install-recommends --yes docker-ce-cli \
71-
&& apt-get clean \
72-
&& rm --recursive --force /var/lib/apt/lists/*
73-
7482
# Install Ent CLI. We mostly then just use it in order to simplify the logic around fetching
7583
# artifacts by URL and ensuring that their digest is correct, in order to ensure reproducibility.
7684
ARG ent_server_url=https://ent-server-62sa4xcfia-ew.a.run.app
@@ -80,8 +88,8 @@ RUN curl --location ${ent_server_url}/raw/${ent_digest} > /usr/local/bin/ent \
8088
&& ent
8189

8290
# Use a fixed version of Bazel.
83-
ARG bazel_version=4.2.0
84-
ARG bazel_digest=sha256:89b14fa0d9ce5637f4e0b66df56a531e1e3c50d88614311334d192531cf1e0fa
91+
ARG bazel_version=5.3.1
92+
ARG bazel_digest=sha256:1e939b50d90f68d30fa4f3c12dfdf31429b83ddd8076c622429854f64253c23d
8593
ARG bazel_url=https://storage.googleapis.com/bazel-apt/pool/jdk1.8/b/bazel/bazel_${bazel_version}_amd64.deb
8694
RUN ent get ${bazel_digest} --url=${bazel_url} > bazel.deb \
8795
&& apt-get install --no-install-recommends --yes ./bazel.deb \
@@ -93,34 +101,10 @@ RUN ent get ${bazel_digest} --url=${bazel_url} > bazel.deb \
93101
# more frequently changed.
94102
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache.
95103

96-
# Install Emscripten.
97-
ARG emscripten_version=1.39.17
98-
# Pick compatible Node version by grepping "node" in the emscripten.zip
99-
# Node is needed to expose npm needed for installing Prettier.
100-
ARG emscripten_node_version_directory=12.9.1_64bit
101-
ARG emscripten_digest=sha256:925dd5ca7dd783d0b367386e81847eaf680d54ae86017c4b5846dea951e17dc9
102-
103-
ARG emscripten_dir=/usr/local/emsdk
104-
ARG emscripten_temp=/tmp/emscripten.zip
105-
RUN mkdir --parents ${emscripten_dir} \
106-
&& ent get ${emscripten_digest} --url=https://github.com/emscripten-core/emsdk/archive/${emscripten_version}.tar.gz > ${emscripten_temp} \
107-
&& tar --extract --gzip --file=${emscripten_temp} --directory=${emscripten_dir} --strip-components=1 \
108-
&& rm ${emscripten_temp} \
109-
&& ${emscripten_dir}/emsdk install ${emscripten_version} \
110-
&& ${emscripten_dir}/emsdk activate --embedded ${emscripten_version}
111-
ENV EMSDK "${emscripten_dir}"
112-
ENV EM_CONFIG "${emscripten_dir}/.emscripten"
113-
ENV EM_CACHE "${emscripten_dir}/.emscripten_cache"
114-
ENV PATH "${emscripten_dir}:${emscripten_dir}/node/${emscripten_node_version_directory}/bin:${PATH}"
115-
# We need to allow a non-root Docker container to write into the directory
116-
RUN chmod --recursive go+wx "${emscripten_dir}"
117-
# Emscripten brings Node with it, we need to allow non-root access to temp and
118-
# config folders
119-
RUN mkdir -p "/.npm" && chmod a+rwx "/.npm" & mkdir -p "/.config" && chmod a+rwx "/.config"
120-
121104
# Install Go.
122-
ARG golang_version=1.17.7
123-
ARG golang_digest=sha256:02b111284bedbfa35a7e5b74a06082d18632eff824fd144312f6063943d49259
105+
# https://go.dev/dl/
106+
ARG golang_version=1.19.2
107+
ARG golang_digest=sha256:5e8c5a74fe6470dd7e055a461acda8bb4050ead8c2df70f227e3ff7d8eb7eeb6
124108
ARG golang_temp=/tmp/golang.tar.gz
125109
ENV GOROOT /usr/local/go
126110
ENV GOPATH ${HOME}/go
@@ -138,21 +122,22 @@ RUN mkdir --parents ${GOROOT} \
138122

139123
# Install embedmd (Markdown snippet embedder) (via Go).
140124
# https://github.com/campoy/embedmd
141-
RUN go get github.com/campoy/embedmd@97c13d6 \
125+
RUN go install github.com/campoy/embedmd@97c13d6 \
142126
&& embedmd -v
143127

144128
# Install liche (Markdown link checker) (via Go).
145129
# https://github.com/raviqqe/liche
146-
RUN go get github.com/raviqqe/liche@f9ba5f2 \
130+
RUN go install github.com/raviqqe/liche@f9ba5f2 \
147131
&& liche --version
148132

149133
# Install prettier and markdownlint (via Node.js).
150134
# This will use the Node version installed by emscripten.
151135
# https://prettier.io/
136+
# https://github.com/prettier/prettier
152137
# https://github.com/igorshubovych/markdownlint-cli
153-
ARG prettier_version=2.5.1
138+
ARG prettier_version=2.7.1
154139
ARG prettier_plugin_toml_version=0.3.1
155-
ARG markdownlint_version=0.30.0
140+
ARG markdownlint_version=0.32.2
156141
RUN npm install --global \
157142
prettier@${prettier_version} \
158143
prettier-plugin-toml@${prettier_plugin_toml_version} \
@@ -162,8 +147,8 @@ RUN npm install --global \
162147

163148
# Install hadolint.
164149
# https://github.com/hadolint/hadolint
165-
ARG hadolint_version=2.8.0
166-
ARG hadolint_digest=sha256:9dfc155139a1e1e9b3b28f3de9907736b9dfe7cead1c3a0ae7ff0158f3191674
150+
ARG hadolint_version=2.10.0
151+
ARG hadolint_digest=sha256:8ee6ff537341681f9e91bae2d5da451b15c575691e33980893732d866d3cefc4
167152
ARG hadolint_dir=/usr/local/hadolint/bin
168153
ARG hadolint_bin=${hadolint_dir}/hadolint
169154
ENV PATH "${hadolint_dir}:${PATH}"
@@ -174,8 +159,8 @@ RUN mkdir --parents ${hadolint_dir} \
174159

175160
# Install buildifier.
176161
# https://github.com/bazelbuild/buildtools/tree/master/buildifier
177-
ARG bazel_tools_version=5.0.0
178-
ARG buildifier_digest=sha256:18a518a4b9b83bb96a115a681099ae6c115217e925a2dacfb263089e3a791b5d
162+
ARG bazel_tools_version=5.1.0
163+
ARG buildifier_digest=sha256:52bf6b102cb4f88464e197caac06d69793fa2b05f5ad50a7e7bf6fbd656648a3
179164
ARG buildifier_dir=/usr/local/buildifier/bin
180165
ARG buildifier_bin=${buildifier_dir}/buildifier
181166
ENV PATH "${buildifier_dir}:${PATH}"
@@ -185,8 +170,9 @@ RUN mkdir --parents ${buildifier_dir} \
185170
&& buildifier --version
186171

187172
# Install Protobuf compiler.
188-
ARG protobuf_version=3.19.4
189-
ARG protobuf_digest=sha256:058d29255a08f8661c8096c92961f3676218704cbd516d3916ec468e139cbd87
173+
# https://github.com/protocolbuffers/protobuf
174+
ARG protobuf_version=3.20.3
175+
ARG protobuf_digest=sha256:44a6b498e996b845edef83864734c0e52f42197e85c9d567af55f4e3ff09d755
190176
ARG protobuf_dir=/usr/local/protobuf
191177
ARG protobuf_temp=/tmp/protobuf.zip
192178
ENV PATH "${protobuf_dir}/bin:${PATH}"
@@ -251,7 +237,12 @@ RUN cargo install --version=${wizer_version} wizer --all-features
251237

252238
# Install crosvm.
253239
# We're not interested in most of the features in crosvm (e.g. wayland support), but GDB support would be nice.
254-
RUN cargo install --git https://chromium.googlesource.com/chromiumos/platform/crosvm/ --rev 31f04e92709980a4ffc56b1631f8b4be437cc2fe crosvm --no-default-features --features gdb
240+
RUN cargo install \
241+
--git=https://chromium.googlesource.com/chromiumos/platform/crosvm/ \
242+
--rev=31f04e92709980a4ffc56b1631f8b4be437cc2fe \
243+
crosvm \
244+
--no-default-features \
245+
--features=gdb
255246

256247
# Where to install rust tooling
257248
ARG install_dir=${rustup_dir}/bin
@@ -296,25 +287,6 @@ RUN chmod +x ${install_dir}/rust-analyzer
296287
# its own home folder.
297288
ENV CARGO_HOME ""
298289

299-
# Build a statically-linked version of OpenSSL with musl
300-
ENV OPENSSL_DIR /musl
301-
RUN mkdir ${OPENSSL_DIR}
302-
303-
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm
304-
RUN ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic
305-
RUN ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
306-
307-
ARG openssl_dir=/usr/local/openssl
308-
RUN mkdir --parents ${openssl_dir}
309-
RUN curl --location https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz | tar --extract --gzip --directory=${openssl_dir}/
310-
WORKDIR ${openssl_dir}/openssl-OpenSSL_1_1_1f
311-
RUN CC="musl-gcc -fPIE -pie" ./Configure no-shared no-async --prefix=/musl --openssldir="${OPENSSL_DIR}/ssl" linux-x86_64
312-
RUN make depend && make -j"$(nproc)"&& make install_sw install_ssldirs
313-
314-
# Allow the build to find statically built OpenSSL.
315-
ENV PKG_CONFIG_ALLOW_CROSS 1
316-
ENV OPENSSL_STATIC 1
317-
318290
# Install sccache
319291
# https://github.com/mozilla/sccache
320292
ARG sccache_version=v0.2.15
@@ -333,12 +305,6 @@ RUN mkdir --parents ${sccache_dir} \
333305
# Ref:https://chromium.googlesource.com/external/github.com/google/flatbuffers/+/750dde766990d75f849370582a0f90307c410537
334306
ARG flatc_commit=750dde766990d75f849370582a0f90307c410537
335307
ARG flatbuffer_tmp_dir=/tmp/flatbuffer
336-
# cmake is required to build flatbuffer
337-
RUN apt-get --yes update \
338-
&& apt-get install --no-install-recommends --yes --option Acquire::http::Dl-Limit=500 \
339-
cmake \
340-
&& apt-get clean \
341-
&& rm --recursive --force /var/lib/apt/lists/*
342308
RUN git clone https://github.com/google/flatbuffers.git ${flatbuffer_tmp_dir}
343309
WORKDIR ${flatbuffer_tmp_dir}
344310
RUN git checkout ${flatc_commit} \
@@ -364,20 +330,52 @@ RUN mkdir --parents ${wasm_pack_dir} \
364330
&& chmod +x ${wasm_pack_bin} \
365331
&& wasm-pack --version
366332

367-
# chromium is required to run our tests with wasm-pack
368-
RUN apt-get --yes update \
369-
&& apt-get install --no-install-recommends --yes --option Acquire::http::Dl-Limit=500 \
370-
chromium \
371-
chromium-driver \
372-
&& apt-get clean \
373-
&& rm --recursive --force /var/lib/apt/lists/*
374-
375333
# By default, sccache uses `~/.cache/sccache` locally: https://github.com/mozilla/sccache#local.
376334
ENV RUSTC_WRAPPER sccache
377335

378336
# Disable cargo incremental compilation, as it conflicts with sccache: https://github.com/mozilla/sccache#rust
379337
ENV CARGO_INCREMENTAL false
380338

339+
# Install Android SDK.
340+
# https://developer.android.com/studio/#downloads
341+
# https://developer.android.com/studio/index.html#command-tools
342+
ARG android_sdk_version=8512546
343+
ENV ANDROID_HOME /opt/android-sdk
344+
ENV android_temp /tmp/android-sdk
345+
RUN mkdir --parents "{android_temp}" \
346+
&& mkdir --parents "${ANDROID_HOME}/cmdline-tools/latest" \
347+
&& curl --location "https://dl.google.com/android/repository/commandlinetools-linux-${android_sdk_version}_latest.zip" > android_sdk.zip \
348+
&& unzip android_sdk.zip -d "${android_temp}" \
349+
&& mv ${android_temp}/cmdline-tools/* "${ANDROID_HOME}/cmdline-tools/latest/" \
350+
&& rm android_sdk.zip
351+
352+
# Install Android Platform Tools.
353+
# https://developer.android.com/studio/releases/platform-tools
354+
# https://developer.android.com/studio/releases/platforms
355+
# https://developer.android.com/studio/releases/build-tools
356+
ARG platform=30
357+
ARG tools=30.0.0
358+
RUN "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --update \
359+
&& (yes || true) | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --licenses \
360+
&& (yes || true) | "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" \
361+
'tools' 'platform-tools' 'cmake;3.6.4111459' \
362+
"platforms;android-${platform}" "build-tools;${tools}" \
363+
"system-images;android-${platform};default;x86_64"
364+
365+
# Set up Android SDK paths.
366+
ENV PATH "${PATH}:${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools/bin"
367+
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${ANDROID_HOME}/emulator/lib64:${ANDROID_HOME}/emulator/lib64/qt/lib"
368+
369+
# Install Android NDK
370+
# https://developer.android.com/ndk/downloads
371+
ARG android_ndk_version=r25b
372+
ENV ANDROID_NDK_HOME /opt/android-ndk
373+
RUN mkdir --parents "${ANDROID_NDK_HOME}" \
374+
&& curl --location "https://dl.google.com/android/repository/android-ndk-${android_ndk_version}-linux.zip" > android_ndk.zip \
375+
&& unzip android_ndk.zip -d "${ANDROID_NDK_HOME}" \
376+
&& mv ${ANDROID_NDK_HOME}/android-ndk-${android_ndk_version}/* "${ANDROID_NDK_HOME}" \
377+
&& rm android_ndk.zip
378+
381379
# To make the scripts available to call from everywhere.
382380
ENV PATH "/workspace/scripts:${PATH}"
383381

0 commit comments

Comments
 (0)