" name="sm-site-verification"/>
侧边栏壁纸
博主头像
PySuper 博主等级

千里之行,始于足下

  • 累计撰写 206 篇文章
  • 累计创建 14 个标签
  • 累计收到 2 条评论

目 录CONTENT

文章目录

Docker 制作项目运行镜像

PySuper
2020-06-21 / 0 评论 / 0 点赞 / 8 阅读 / 0 字
温馨提示:
本文最后更新于2024-05-28,若内容或图片失效,请留言反馈。 所有牛逼的人都有一段苦逼的岁月。 但是你只要像SB一样去坚持,终将牛逼!!! ✊✊✊

目录结构

  • Dockerfile:构建镜像的文件
  • Project:项目目录
  • pip.conf:pip的配置文件
  • run_web.sh:启动项目的脚本

Dockerfile

在使用apt安装软件包时,时不时会遇到提示Y/N的选择,一般情况下,需要手动输入
我们可以设置其自动输入Y:apt-get -y install vim

# Django Web Base
FROM python:3.6
RUN apt-get update && apt-get install -y vim && pip3 install django==1.11 && pip3 install uwsgi && pip3 install pymysql

pip.conf

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

run_web.sh

uwsgi --ini uwsgi_dev.ini

requirements.txt

# pip install -r requirements.txt

backports.csv==1.0.7
certifi==2019.9.11
chardet==3.0.4
coreapi==2.3.3
coreschema==0.0.4
defusedxml==0.6.0
diff-match-patch==20181111
Django==1.11
django-appconf==1.0.3
django-ckeditor==5.7.1
django-crispy-forms==1.7.2
django-emoji==2.2.2
django-formtools==2.1
django-haystack==2.8.1
django-imagekit==4.0.2
django-import-export==1.2.0
django-js-asset==1.2.2
django-qiniu-storage==2.3.1
django-reversion==3.0.4
djangorestframework==3.9.4
drf-haystack==1.8.5
et-xmlfile==1.0.1
future==0.17.1
httplib2==0.9.2
idna==2.8
itypes==1.1.0
jdcal==1.4.1
jieba==0.39
Jinja2==2.10.1
Markdown==3.1.1
MarkupSafe==1.1.1
odfpy==1.4.0
openpyxl==2.6.3
pilkit==2.0
Pillow==6.1.0
Pygments==2.4.2
PyMySQL==0.9.3
python-dateutil==2.8.0
pytz==2019.2
PyYAML==5.1.2
qiniu==7.2.6
requests==2.22.0
six==1.12.0
sqlparse==0.3.0
tablib==0.13.0
uritemplate==3.0.0
urllib3==1.25.3
Whoosh==2.7.4
https://github.com/sshwsfc/xadmin/tarball/master
xlrd==1.2.0
xlwt==1.3.0

nginx.conf

# 创建用户组
groupadd -r nginx
useradd -r -g nginx nginx

# 创建配置文件
vim /etc/nginx/sites-available/site.conf

# nginx文件
server {
    listen 80;
    charset utf-8;
    client_max_body_size 75M;
    location /front_end {
        alias /home/zheng/Documents/Project/Work/INFO/front_end/;
    }
    location / {
        uwsgi_pass 0.0.0.0:8000;
        include /etc/nginx/uwsgi_params;
    }
}

# 加载配置文件,重启nginx
sudo ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf
nginx -s reload
sudo service nginx restart

创建镜像

-- 制作镜像
docker build -f Dockerfile -t zheng/blog:v1 .

-- 打包镜像
docker save zheng/blog > zheng-blog.tar.gz

-- 修改镜像名:标签(smallspider必须和dockerhub的账号一致)
docker tag image_id smallspider/django:latest smallspider/django-test:v1

-- 上传Docker Hub
docker push smallspider/django:latest
0

评论区