django-xadmin docker镜像

一、目录结构:

django-xadmin docker镜像

django-xadmin docker镜像

pip.conf文件:

[global]index-url = https://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com

requirements.txt文件:

Django==2.2.2PyMySQL==0.9.3xlrd==1.2.0XlsxWriter==1.1.8xlwt==1.3.0uWSGI==2.0.18uwsgitop==0.1

Dockerfile文件:

FROM ubuntu:18.04# 基础镜像MAINTAINER yangjianliang <># 作者RUN sed -i /archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list# 设置apt源为阿里云源RUN apt-get clean && \    apt-get update && \    apt-get upgrade -y# 检查软件包并升级RUN apt-get update && \    apt-get install -y \   python3 && \   apt-get update && \   apt-get install -y \   python3-dev \   python3-setuptools && \   apt-get update && \   apt-get install -y \   python3-pip && \   apt-get update && \   apt-get install -y \   language-pack-zh-hans* &&\   apt-get update && \   ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \   apt-get install -y \   tzdata && \   rm -rf /var/lib/apt/lists/*# 安装软件COPY pip.conf /root/.pip/pip.conf# 复制pip配置文件COPY requirements.txt /home/# 拷贝requirements.txtCOPY xadmin-django2.zip /home/# 拷贝xadmin-django2.zipRUN pip3 install /home/xadmin-django2.zip && \pip3 install -r /home/requirements.txt# 安装python依赖库RUN sed -i ‘35,36d‘ /usr/local/lib/python3.6/dist-packages/django/db/backends/mysql/base.py && \sed -i ‘145,146d‘ /usr/local/lib/python3.6/dist-packages/django/db/backends/mysql/operations.py && \sed -i ‘93d‘ /usr/local/lib/python3.6/dist-packages/django/forms/boundfield.py# 修改Django源码ENV LANG zh_CN.UTF-8ENV LANGUAGE zh_CN.UTF-8ENV LC_ALL zh_CN.UTF-8# 设置环境变量,选择zh_CN.UTF-8作为默认字符集,用以支持中文ENV PYTHONUNBUFFERED=1# 设置环境变量,不缓冲,等同于python3 -u

二、打包镜像:

docker build -t django_xadmin .

三、推送到阿里云镜像仓库:

sudo docker login --username=yangjianliang2017 registry.cn-hangzhou.aliyuncs.com
登录阿里云Docker Registry
sudo docker tag 1c389de93b60 registry.cn-hangzhou.aliyuncs.com/yangjianliang/django_xadmin:0.0.1
给本地镜像打tag
sudo docker push registry.cn-hangzhou.aliyuncs.com/yangjianliang/django_xadmin:0.0.1
推送到阿里云镜像仓库
sudo docker pull registry.cn-hangzhou.aliyuncs.com/yangjianliang/django_xadmin:0.0.1
从Registry中拉取镜像

四、从阿里云后台管理界面搜索镜像:

django-xadmin docker镜像

相关推荐