这几天需要部署众家云官网自动化部署djanggo和python要命的事:
这是写在自动化部署里面:
image.png
docker image prune -af
sleep 1
docker rm -f zencloud-site
sleep 1
tee zencloud-site/run.sh <<-'EOF'
#!/bin/bash
nohup python /data-web/manage.py runserver >logs/runserver.log 2>&1 &
nohup gunicorn -w4 -b0.0.0.0:8000 zencloudweb.wsgi >logs/gunicorn.log
EOF
tee zencloud-site/Dockerfile <<-'EOF'
FROM python:3.6
RUN mkdir ~/.pip
RUN echo "[global]\ntrusted-host=mirrors.aliyun.com\nindex-url=https://mirrors.aliyun.com/pypi/simple/\n" > ~/.pip/pip.conf
ENV DJANGO_VERSION 1.11
RUN pip install --no-cache-dir pymysql django-ckeditor gunicorn markdown pillow django=="$DJANGO_VERSION"
EXPOSE 8000
RUN mkdir -p /data-web
WORKDIR /data-web
COPY run.sh /run.sh
RUN chmod +x /run.sh
CMD ["sh", "/run.sh"]
EOF
docker build zencloud-site/ -t zencloud-site
docker run -d -p 8020:8000 --name zencloud-site -v /root/zencloud-site/data-web:/data-web/ -v /root/zencloud-site/logs:/data-web/logs/ zencloud-site
这里就安装好啦:
可以进入容器内部查看安装的东西: pip freeze
image.png
在python里面查看数据库链接情况:
pymysql.connect(host="111.41.114.226",user="zenhome_test", password="root",db="zencloud_site",port=3306)
image.png
网友评论