Dockerfile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # The base-deps Docker image installs main libraries needed to run Ray
  2. # The GPU option is nvidia/cuda:11.2.0-cudnn8-devel-ubuntu18.04
  3. ARG BASE_IMAGE="ubuntu:focal"
  4. FROM ${BASE_IMAGE}
  5. # FROM directive resets ARG
  6. ARG BASE_IMAGE
  7. # If this arg is not "autoscaler" then no autoscaler requirements will be included
  8. ARG AUTOSCALER="autoscaler"
  9. ENV TZ=America/Los_Angeles
  10. # TODO(ilr) $HOME seems to point to result in "" instead of "/home/ray"
  11. ENV PATH "/home/ray/anaconda3/bin:$PATH"
  12. ARG DEBIAN_FRONTEND=noninteractive
  13. ARG PYTHON_VERSION=3.7.7
  14. ARG RAY_UID=1000
  15. ARG RAY_GID=100
  16. RUN apt-get update -y \
  17. && apt-get install -y sudo tzdata \
  18. && useradd -ms /bin/bash -d /home/ray ray --uid $RAY_UID --gid $RAY_GID \
  19. && usermod -aG sudo ray \
  20. && echo 'ray ALL=NOPASSWD: ALL' >> /etc/sudoers \
  21. && rm -rf /var/lib/apt/lists/* \
  22. && apt-get clean
  23. USER $RAY_UID
  24. ENV HOME=/home/ray
  25. RUN sudo apt-get update -y && sudo apt-get upgrade -y \
  26. && sudo apt-get install -y \
  27. git \
  28. wget \
  29. cmake \
  30. g++ \
  31. zlib1g-dev \
  32. $(if [ "$AUTOSCALER" = "autoscaler" ]; then echo \
  33. tmux \
  34. screen \
  35. rsync \
  36. openssh-client \
  37. gnupg; fi) \
  38. && wget \
  39. --quiet "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" \
  40. -O /tmp/miniconda.sh \
  41. && /bin/bash /tmp/miniconda.sh -b -u -p $HOME/anaconda3 \
  42. && $HOME/anaconda3/bin/conda init \
  43. && echo 'export PATH=$HOME/anaconda3/bin:$PATH' >> /home/ray/.bashrc \
  44. && rm /tmp/miniconda.sh \
  45. && $HOME/anaconda3/bin/conda install -y \
  46. libgcc python=$PYTHON_VERSION \
  47. && $HOME/anaconda3/bin/conda clean -y --all \
  48. && $HOME/anaconda3/bin/pip install --no-cache-dir \
  49. flatbuffers \
  50. cython==0.29.23 \
  51. numpy==1.19.5 \
  52. psutil \
  53. blist \
  54. atari-py \
  55. # blist is needed for numpy (which is re-installed when ray is installed)
  56. # atari-py is built from source for Python 3.8 (requires g++ & zlib1g-dev)
  57. # To avoid the following error on Jenkins:
  58. # AttributeError: 'numpy.ufunc' object has no attribute '__module__'
  59. && $HOME/anaconda3/bin/pip uninstall -y dask \
  60. # We install cmake temporarily to get psutil, blist & atari-py
  61. && sudo apt-get autoremove -y cmake zlib1g-dev \
  62. # We keep g++ on GPU images, because uninstalling removes CUDA Devel tooling
  63. $(if [ "$BASE_IMAGE" = "ubuntu:focal" ]; then echo \
  64. g++; fi) \
  65. # Either install kubectl or remove wget
  66. && (if [ "$AUTOSCALER" = "autoscaler" ]; \
  67. then wget -O - -q https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - \
  68. && sudo touch /etc/apt/sources.list.d/kubernetes.list \
  69. && echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list \
  70. && sudo apt-get update \
  71. && sudo apt-get install kubectl; \
  72. else sudo apt-get autoremove -y wget; \
  73. fi;) \
  74. && sudo rm -rf /var/lib/apt/lists/* \
  75. && sudo apt-get clean
  76. WORKDIR $HOME