django_simpleui docker映象
一、目錄結構:
pip.conf檔案:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
requirements.txt檔案:
Django==2.2.2
django-simpleui==4.0.3
PyMySQL==0.9.3
xlrd==1.2.0
XlsxWriter==1.1.8
xlwt==1.3.0
uWSGI==2.0.18
uwsgitop==0.1
Dockerfile檔案:
FROM ubuntu:18.04
# 基礎映象
MAINTAINER yangjianliang <[email protected]>
RUN sed -i s@/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-setuptools && \
apt-get update && \
apt-get install -y \
python3-pip && \
apt-get update && \
apt-get install -y \
wget \
nginx \
redis-server \
supervisor && \
apt-get update && \
apt-get install -y \
language-pack-zh-hans* &&\
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.txt
RUN 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-8
ENV LANGUAGE zh_CN.UTF-8
ENV LC_ALL zh_CN.UTF-8
# 設定環境變數,選擇zh_CN.UTF-8作為預設字符集,用以支援中文
ENV PYTHONUNBUFFERED=1
# 設定環境變數,不緩衝,等同於python3 -u
二、打包映象:
docker build -t django_simpleui .
django_simpleui為映象名稱,別忘記了最後面的.
三、推送到阿里雲映象倉庫:
sudo docker login --username=yangjianliang2017 registry.cn-hangzhou.aliyuncs.com
登入阿里雲Docker Registry
sudo docker tag14b4cd201ca0 registry.cn-hangzhou.aliyuncs.com/yangjianliang/django_simpleui:0.0.1
給本地映象打tag
sudo docker push registry.cn-hangzhou.aliyuncs.com/yangjianliang/django_simpleui:0.0.1
推送到阿里雲映象倉庫
sudo docker pull registry.cn-hangzhou.aliyuncs.com/yangjianliang/django_simpleui:0.0.1
從Registry中拉取映象
四、從阿里雲後臺管理介面搜尋映象: