GitHub:https://github.com/yjlch1016/dapi
QQ 群:529063263
我的博客:https://www.cnblogs.com/yjlch1016/
第 1 个帖子:https://testerhome.com/topics/20582
第 2 个帖子:https://testerhome.com/topics/20601
第 3 个帖子:https://testerhome.com/topics/20713
第 4 个帖子:https://testerhome.com/topics/20931
第 5 个帖子:https://testerhome.com/topics/21126
第 6 个帖子:https://testerhome.com/topics/21082
第 7 个帖子:https://testerhome.com/topics/21141
采用 Docker+Supervisor+Nginx+uWSGI+Django
一、Dockerfile 文件:
FROM ubuntu:18.04
MAINTAINER yangjianliang 526861348@qq.com
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean && \
apt-get update && \
apt-get upgrade -y
RUN apt-get install -y \
git \
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 \
nginx \
supervisor &&\
apt-get update && \
ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
apt-get install -y \
tzdata && \
rm -rf /var/lib/apt/lists/*
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY deploy_conf/nginx-app.conf /etc/nginx/sites-available/default
COPY deploy_conf/supervisor-app.conf /etc/supervisor/conf.d/
COPY deploy_conf/pip.conf /root/.pip/pip.conf
RUN pip3 install https://codeload.github.com/sshwsfc/xadmin/zip/django2
COPY requirements.txt /django/dapi/
RUN pip3 install -r /django/dapi/requirements.txt
COPY . /django/dapi/
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
EXPOSE 80
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisor-app.conf"]
二、打包:
docker build -t dapi .
等待一会儿
网速慢的话十分钟吧
三、运行:
docker run -d --name dapi1.0 -p 80:80 dapi:latest
docker inspect dapi1.0
docker exec -it dapi1.0 /bin/bash
supervisord -c /etc/supervisor/conf.d/supervisor-app.conf
访问(宿主机的 IP 地址):
http://192.168.1.102/
账号:admin
密码:test123456
后台:
http://192.168.1.102/admin/
账号:admin
密码:test123456