123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- # 拉取镜像
- FROM centos:centos7.9.2009
- # 配置容器时间
- RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
- # 添加快捷命令
- RUN echo "alias ll='ls -hall'" >> ~/.bashrc && source ~/.bashrc
- # 更新yum源
- RUN curl -o /etc/yum.repos.d/CentOS7-Aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo && curl -o /etc/yum.repos.d/epel-7-Aliyun.repo http://mirrors.aliyun.com/repo/epel-7.repo
- RUN yum clean all && yum makecache && yum -y update
- RUN yum install -y kde-l10n-Chinese
- # 设置系统编码
- ENV LANG=zh_CN.UTF-8
- # 设置vi编码(防止中文乱码)
- RUN grep -qxF 'set encoding=utf8' /etc/virc || echo 'set encoding=utf8' >> /etc/virc
- WORKDIR /opt
- # 安装 python3.8.10 gcc相关配置
- RUN yum --exclude=kernel* update -y && yum groupinstall -y 'Development Tools' && yum install -y gcc openssl-devel bzip2-devel libffi-devel mesa-libGL
- # python3.8.10下载与解压缩
- RUN curl -o python3.8.10.tgz https://mirrors.huaweicloud.com/python/3.8.10/Python-3.8.10.tgz && tar -zxvf python3.8.10.tgz
- # 设置Python3虚拟环境路径
- ENV VIRTUAL_ENV=/usr/local/python38
- # 切换路径
- WORKDIR /opt/Python-3.8.10
- # 创建安装目录, 指定安装目录
- RUN mkdir $VIRTUAL_ENV && ./configure --prefix=$VIRTUAL_ENV
- # 编译、安装
- RUN make -j 8 && make altinstall
- # 创建python3的软连接
- RUN rm -rf /usr/bin/python3 /usr/bin/pip3 && ln -s $VIRTUAL_ENV/bin/python3.8 /usr/bin/python3 && ln -s $VIRTUAL_ENV/bin/pip3.8 /usr/bin/pip3
- # 更换pip源&更新pip
- RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && pip3 install --upgrade pip
- # python3虚拟环境加入系统环境变量
- ENV PATH="$VIRTUAL_ENV/bin:$PATH"
- # 指定应用安装目录
- WORKDIR /app
- # 复制当前目录文件到容器/app目录下
- COPY requirements.txt requirements.txt
- # 安装python项目依赖
- RUN pip3 install -r requirements.txt
- # 指定工作目录
- WORKDIR /mnt
|