Dockerfile 配置linux 环境、python
# 基础镜像使用cuda
FROM nvidia/cuda:10.0-cudnn7-runtime-ubuntu18.04
# 配置程序依赖环境
RUN apt-get update && apt-get install -y --no-install-recommends
build-essential
cmake
curl
ca-certificates
libjpeg-dev
libglib2.0-dev
libgl1-mesa-glx
openssl
libssl-dev
libpng-dev &&
rm -rf /var/lib/apt/lists/* &&
apt-get purge -y python.*
# 删除旧的 python
# RUN apt-get purge -y python.*
# 使用 UTF-8 编码
ENV LANG C.UTF-8
ENV PYTHON_VERSION 3.6.5
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''"
ENV PYTHON_PIP_VERSION 21.1.3
# 将程序复制容器内,表示在/workspace 路径下
COPY . /workspace
RUN set -ex
# && curl -fSL "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" -o python.tar.xz
&& mkdir -p /usr/src/python
&& tar -xJC /usr/src/python --strip-components=1 -f /workspace/python.tar.xz
&& rm /workspace/python.tar.xz
&& cd /usr/src/python
&& ./configure --enable-shared --enable-unicode=ucs4
&& make -j$(nproc)
&& make install
&& ldconfig
&& pip3 install --no-cache-dir --upgrade --ignore-installed pip==$PYTHON_PIP_VERSION
&& find /usr/local -depth
(
( -type d -a -name test -o -name tests )
-o
( -type f -a -name '*.pyc' -o -name '*.pyo' )
) -exec rm -rf '{}' +
&& rm -rf /usr/src/python ~/.cache
# make some useful symlinks that are expected to exist
RUN cd /usr/local/bin
&& ln -s easy_install-3.5 easy_install
&& ln -s idle3 idle
&& ln -s pydoc3 pydoc
&& ln -s python3 python
&& ln -s python3-config python-config
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
&& pip install tqdm joblib numpy scikit-learn scipy
# 确定容器启动时程序运行路径
WORKDIR /workspace
# 确定容器启动命令。以python 示例,python 表示编译器,
CMD ["python"]