Skip to content

Commit

Permalink
Adds a dockerfile.
Browse files Browse the repository at this point in the history
To run a test like
```
bazel run :python_random_agent --define graphics=sdl -- --length=10000 --width=640 --height=480
```
use
```
docker build -t lab .
docker run lab bazel run :python_random_agent --define graphics=sdl -- --length=10000 --width=640 --height=480
```
  • Loading branch information
andyljones committed Apr 21, 2019
1 parent ef541f1 commit 4fd9acb
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .docker/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Based on Frank Carey's pull request
# https://github.com/deepmind/lab/pull/24

# Remove VNC lock (if process already killed)
rm -f /tmp/.X1-lock /tmp/.X11-unix/X1

# Set the DISPLAY that will be used by default. Makes lab show up in our xvfb display
export DISPLAY=:1

# Start the X virtual frame buffer which uses memory instead of an actual device.
# Allows lab to be run headless.
echo "Launching xvfb"
Xvfb "$DISPLAY" -screen 0 "$XVFB_RESOLUTION" &

# Run a lightweight Window Manager (fluxbox is smaller than lxdm, gnome, unity, kde, etc)
# (pretty sure this is required.)
echo "Launching fluxbox"
fluxbox &

# Run the x11vnc server
# Explanation of options:
# -display : This needs to match the xvfb display number
# -passwd : Use the password from an ENV var here instead of using ~/.vnc/passwd
# -o : Specifies where to send the log output.
# -noipv6 : Skip trying to serve vnc on ipv6 (avoids warnings)
# -bg : Run in the background
# -forever : Don't die when the first user disconnects from vnc (which is the default)
# -N : Makes it use port 5900+N where N is the display.. so 5901. (default is 5900)
echo "Launching x11vnc"
x11vnc \
-display "$DISPLAY" \
-passwd "$VNC_PASSWORD" \
-o /dev/stderr \
-noipv6 \
-bg \
-forever \
-N

# Launching whatever the additional command is
echo "Launching $@"
"$@"
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs
.git
68 changes: 68 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Based on Frank Carey's pull request
# https://github.com/deepmind/lab/pull/24

FROM l.gcr.io/google/bazel:latest

# Temporarily shut up warnings.
ENV DISPLAY :0
ENV TERM xterm

# Basic Dependencies
RUN apt-get update && apt-get install -y \
curl \
zip \
unzip \
software-properties-common \
python-software-properties && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Dependencies for vnc setup.
RUN apt-get update && apt-get install -y \
xvfb \
fluxbox \
x11vnc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install deepmind-lab dependencies
RUN apt-get update && apt-get install -y \
lua5.1 \
liblua5.1-0-dev \
libffi-dev \
gettext \
freeglut3-dev \
libsdl2-dev \
libosmesa6-dev \
python-dev \
python-numpy \
realpath \
build-essential && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*


# Set the default X11 Display.
ENV DISPLAY :1
ENV VNC_PASSWORD=password
ENV XVFB_RESOLUTION=800x600x16

# Set up deepmind-lab folder and copy in the code.
ENV lab_dir /lab
RUN mkdir /$lab_dir
COPY . /$lab_dir
WORKDIR $lab_dir

# Run an actual (headless) build since this should make subsequent builds much faster.
RUN bazel build -c opt //:deepmind_lab.so --define headless=osmesa && \
bazel test -c opt //python/tests:python_module_test

# This port is the default for connecting to VNC display :1
EXPOSE 5901

# Copy VNC script that handles restarts and make it executable.
COPY ./.docker/startup.sh /opt/
RUN chmod u+x /opt/startup.sh

# Finally, start VNC using our script.
ENTRYPOINT ["/opt/startup.sh"]

0 comments on commit 4fd9acb

Please sign in to comment.