Dockerfile模板
FROM python:latestWORKDIR /root/RUN mkdir /etc/supervisor # 创建存放supervisor配置文件的文件夹
RUN mkdir -p /root/projects/logs/gunicorn/ # 创建gunicorn日志文件夹 要和supervisor中gunicorn日志文件路径一致
RUN mkdir -p /root/projects/logs/celery/ # 创建celery日志文件夹 要和supervisor中celery日志文件路径一致
ADD sy.ini /etc/supervisor/sy.ini # 复制本地的supervisor配置文件到镜像内# 根据具体项目名称替换Sy_EvaluateJkApi
ADD Sy_EvaluateJkApi /root/projects/Sy_EvaluateJkApi # 复制代码到镜像内
RUN pip3 install -r /root/projects/Sy_EvaluateJkApi/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ #安装python相关包
RUN mkdir -p /root/projects/Sy_EvaluateJkApi/logs/ # 创建项目日志文件夹RUN pip install supervisor -i https://mirrors.aliyun.com/pypi/simple/
RUN pip install gunicorn -i https://mirrors.aliyun.com/pypi/simple/
RUN pip install gevent -i https://mirrors.aliyun.com/pypi/simple/
RUN pip install eventlet-i https://mirrors.aliyun.com/pypi/simple/
RUN /usr/local/bin/echo_supervisord_conf > /etc/supervisor/supervisord.conf
RUN echo "[include]">>/etc/supervisor/supervisord.conf
RUN echo "files = /etc/supervisor/*.ini">>/etc/supervisor/supervisord.confEXPOSE 8800 # 容器暴露的端口与sy.ini内启动项目的端口必须一致
CMD ["supervisord","-n","-c","/etc/supervisor/supervisord.conf"]
supervisor配置文件文件模板
[group:sy_group]
programs=sy,celery_work,celery_beat
priority=5[program:sy]
command=gunicorn --limit-request-line 8188-w 1 -k gevent -b 0.0.0.0:8800 EvaluateJK.wsgi -e DJANGO_SETTINGS_MODULE=EvaluateJK.settings.dev
directory=/root/projects/Sy_EvaluateJkApi;
directory to cwd to before exec (def no cwd)
priority=5;
the relative start priority (default 999)
autostart=true;
start at supervisord start (default: true)
startsecs=15;
# of secs prog must stay up to be running (def. 1)
startretries=3;
max # of serial start failures when starting (default 3)
autorestart=true;
when to restart if exited after running (def: unexpected)
stopsignal=QUIT;
signal used to kill process (default TERM)
stopwaitsecs=0;
max num secs to wait b4 SIGKILL (default 10)
user=root;
setuid to this UNIX account to run the program
stdout_logfile=/root/projects/logs/gunicorn/sy_success.log;
stdout log path, NONE for none;
default AUTO
stderr_logfile=/root/projects/logs/gunicorn/sy_error.err;
stderr log path, NONE for none;
default AUTO[program:celery_work]
command=celery -A EvaluateJK worker -l info -P eventlet --logfile=/root/projects/logs/celery/celery_worker.log
directory=/root/projects/Sy_EvaluateJkApi
priority=5;
the relative start priority (default 999)
startsecs=15;
# of secs prog must stay up to be running (def. 1)
startretries=3;
max # of serial start failures when starting (default 3)
autorestart=true;
when to restart if exited after running (def: unexpected)
stopsignal=QUIT;
signal used to kill process (default TERM)
stopwaitsecs=0;
max num secs to wait b4 SIGKILL (default 10)
user=root;
setuid to this UNIX account to run the program
stdout_logfile=/root/projects/logs/celery/celery.log
stderr_logfile=/root/projects/logs/celery/celery.err[program:celery_beat]
command=celery -A EvaluateJK beat -l info --logfile=/root/projects/logs/celery/celery_beat.log
directory=/root/projects/Sy_EvaluateJkApi
priority=5;
the relative start priority (default 999)
startsecs=15;
# of secs prog must stay up to be running (def. 1)
startretries=3;
max # of serial start failures when starting (default 3)
autorestart=true;
when to restart if exited after running (def: unexpected)
stopsignal=QUIT;
signal used to kill process (default TERM)
stopwaitsecs=0;
max num secs to wait b4 SIGKILL (default 10)
user=root;
setuid to this UNIX account to run the program
stdout_logfile=/root/projects/logs/celery/celery_beat.log
stderr_logfile=/root/projects/logs/celery/celery_beat.err
【Dockerfile和supervisor部署项目配置文件模板】
推荐阅读
- 其他|有趣的10个CMD命令
- 其他|清理C盘内存(电脑C盘飘红了,那么如何清理垃圾文件,总结几种亲测方案)
- 其他|如何复制百度文库中的内容
- 谈谈base中遇到的坑点 及 其他
- 用VS Code画uml
- Mac 安装Android Studio3.0安装和卸载总结
- 其他|c++读取TXT文件内容
- util|POI兼容读取Excel2003和Excel2007
- java|Junit4精简解析
- 解决Adobe Reader XI打开就后崩溃问题