This repository has been archived by the owner on Oct 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerfile: enable RUN --mount=type=cache
Signed-off-by: Akihiro Suda <[email protected]>
- Loading branch information
1 parent
99ee195
commit 70a64a8
Showing
3 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# this dockerfile can be translated to `docker/dockerfile:1-experimental` syntax for enabling cache mounts: | ||
# $ ./hack/translate-dockerfile-runopt-directive.sh < Dockerfile | DOCKER_BUILDKIT=1 docker build -f - . | ||
|
||
ARG BASE=ubuntu:20.04 | ||
|
||
# Apr 14, 2020 | ||
|
@@ -56,10 +59,11 @@ COPY ./src/patches/anbox /patches | |
RUN git config user.email "[email protected]" && \ | ||
git config user.name "AinD Build Script" && \ | ||
git am /patches/* && git show --summary | ||
RUN mkdir build && \ | ||
cd build && \ | ||
cmake .. && \ | ||
make -j10 anbox | ||
# runopt = --mount=type=cache,id=aind-anbox,target=/build | ||
RUN mkdir -p /build && cd /build && \ | ||
cmake ../anbox && \ | ||
make -j10 anbox && \ | ||
cp -f ./src/anbox /anbox-binary | ||
|
||
FROM ${BASE} AS android-img | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
@@ -112,7 +116,7 @@ RUN mkdir -p /apk-pre.d /apk.d && \ | |
chmod 444 /apk-pre.d/* | ||
COPY --from=lxc /usr/local /usr/local/ | ||
COPY --from=android-img /android.img /aind-android.img | ||
COPY --from=anbox /anbox/build/src/anbox /usr/local/bin/anbox | ||
COPY --from=anbox /anbox-binary /usr/local/bin/anbox | ||
COPY --from=anbox /anbox/scripts/anbox-bridge.sh /usr/local/share/anbox/anbox-bridge.sh | ||
COPY --from=anbox /anbox/data/ui /usr/local/share/anbox/ui | ||
RUN ldconfig | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
# From https://raw.githubusercontent.com/rootless-containers/usernetes/v20200309.0/hack/translate-dockerfile-runopt-directive.sh | ||
|
||
# Input: | ||
# FROM ... | ||
# ... | ||
# # runopt = --mount=type=cache,target=/root/.cache | ||
# RUN foo | ||
|
||
# Output: | ||
# # syntax = docker/dockerfile:1-experimental | ||
# FROM ... | ||
# ... | ||
# RUN --mount=type=cache,target=/root/.cache foo | ||
|
||
echo '# syntax = docker/dockerfile:1-experimental' | ||
|
||
last_runopt="" | ||
while IFS="" read -r line || [[ -n $line ]]; do | ||
run=$(echo $line | grep -ioP '^\s*RUN\s+\K.+') | ||
printed="" | ||
if [[ -n $run && -n $last_runopt ]]; then | ||
echo "RUN $last_runopt $run" | ||
printed=1 | ||
fi | ||
last_runopt=$(echo $line | grep -ioP '^#\s*runopt\s*=\s*\K.+') | ||
if [[ -z $last_runopt && -z $printed ]]; then | ||
echo "$line" | ||
fi | ||
done |