docker: make using X11 gpu display easier with docker

This change makes using docker a bit easier when displaying on the hosts
X11 server. The biggest change was that build_crosvm.sh will install the
hosts NVIDIA proprietary driver if needed.

TEST=docker/build_crosvm.sh
     docker/crosvm_wrapper.sh
BUG=None

Change-Id: If64074715b0ad3a06727a4cc764d3ac06c4dfece
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1759139
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Zach Reizner 2019-08-16 15:37:46 -07:00 committed by Commit Bot
parent 373673c43a
commit 971589f7ec
4 changed files with 26 additions and 5 deletions

View file

@ -10,14 +10,15 @@ RUN apt-get update && apt-get install -y \
autoconf \
automake \
curl \
gcc \
g++ \
gcc \
git \
kmod \
libcap-dev \
libdbus-1-dev \
libdrm-dev \
libfdt-dev \
libegl1-mesa-dev \
libfdt-dev \
libgl1-mesa-dev \
libgles1-mesa-dev \
libgles2-mesa-dev \

View file

@ -2,7 +2,7 @@ FROM crosvm-base
COPY . /platform/crosvm
RUN cargo install --features 'default-no-sandbox wl-dmabuf gpu' --path . --root /usr
RUN cargo install --features 'default-no-sandbox wl-dmabuf gpu x' --path . --root /usr
ARG UID=1000
ARG GID=1000
@ -13,4 +13,14 @@ RUN export uid=$UID gid=$GID && \
echo "chronos:x:${uid}:" >> /etc/group && \
chown ${uid}:${gid} -R /home/chronos
# Install nvidia proprietary drivers if requested.
ARG NVIDIA_VERSION=
RUN if [ -n NVIDIA_VERSION ]; then \
nvidia_url=http://us.download.nvidia.com/XFree86/Linux-x86_64 && \
nvidia_binary=NVIDIA-Linux-x86_64-"${NVIDIA_VERSION}".run && \
curl -LO "${nvidia_url}"/"${NVIDIA_VERSION}"/"${nvidia_binary}" && \
chmod +x ./"${nvidia_binary}" && \
./"${nvidia_binary}" --accept-license --silent --no-kernel-module; \
fi
ENTRYPOINT ["crosvm"]

View file

@ -6,11 +6,16 @@
set -ex
cd "${0%/*}"
if command -v nvidia-smi >/dev/null 2>&1; then
export NVIDIA_VERSION="$(nvidia-smi -q | grep "Driver Version" | cut -d':' -f 2 | xargs)"
fi
src_root="$(realpath ..)"
docker build -t crosvm \
-f Dockerfile.crosvm \
--build-arg UID \
--build-arg GID \
--build-arg NVIDIA_VERSION \
"$@" \
"${src_root}"

View file

@ -4,14 +4,19 @@
# found in the LICENSE file.
set -ex
# grab the pwd before changing it to this script's directory
pwd="${PWD}"
cd "${0%/*}"
exec docker run -it --rm \
--privileged \
--ipc=host \
-e DISPLAY=$DISPLAY -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-v /dev/log:/dev/log \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--volume "$PWD":/wd \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--volume "$pwd":/wd \
--workdir /wd \
crosvm \
"$@"