In Dockerfile, do not install unecessary packages, use conda to install ninja (saving one layer), and use "." to refer to WORKDIR to reduce redundancy. (#20881)

Summary:
- Do not install unecessary packages in the Docker image.
- In the Docker image, use conda to install ninja (saving one layer)
- When workdir is set, use "." to refer to it to reduce redundancy.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20881

Differential Revision: D15495769

Pulled By: ezyang

fbshipit-source-id: dab7df71ac107c85fb1447697e25978daffc7e0b
This commit is contained in:
Hong Xu
2019-05-24 09:16:18 -07:00
committed by Facebook Github Bot
parent 6af2482612
commit 4109ec1278

View File

@ -5,10 +5,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \ cmake \
git \ git \
curl \ curl \
vim \
ca-certificates \ ca-certificates \
libjpeg-dev \ libjpeg-dev \
libpng-dev &&\ libpng-dev && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
@ -16,11 +15,10 @@ RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-la
chmod +x ~/miniconda.sh && \ chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \ ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \ rm ~/miniconda.sh && \
/opt/conda/bin/conda install -y python=$PYTHON_VERSION numpy pyyaml scipy ipython mkl mkl-include cython typing && \ /opt/conda/bin/conda install -y python=$PYTHON_VERSION numpy pyyaml scipy ipython mkl mkl-include ninja cython typing && \
/opt/conda/bin/conda install -y -c pytorch magma-cuda100 && \ /opt/conda/bin/conda install -y -c pytorch magma-cuda100 && \
/opt/conda/bin/conda clean -ya /opt/conda/bin/conda clean -ya
ENV PATH /opt/conda/bin:$PATH ENV PATH /opt/conda/bin:$PATH
RUN pip install ninja
# This must be done before pip so that requirements.txt is available # This must be done before pip so that requirements.txt is available
WORKDIR /opt/pytorch WORKDIR /opt/pytorch
COPY . . COPY . .
@ -33,4 +31,4 @@ RUN TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1 7.0+PTX" TORCH_NVCC_FLAGS="-Xfatbin -c
RUN git clone https://github.com/pytorch/vision.git && cd vision && pip install -v . RUN git clone https://github.com/pytorch/vision.git && cd vision && pip install -v .
WORKDIR /workspace WORKDIR /workspace
RUN chmod -R a+w /workspace RUN chmod -R a+w .