docker 内 server 降权运行

This commit is contained in:
virusdefender 2016-01-08 23:32:30 +08:00
parent 8bf4166d5d
commit 6aaa31386b
6 changed files with 27 additions and 30 deletions

View File

@ -1,5 +1,4 @@
FROM ubuntu:14.04
MAINTAINER virusdefender<qduliyang@outlook.com>
RUN mkdir /var/install/
WORKDIR /var/install/
ENV DEBIAN_FRONTEND noninteractive

View File

@ -1,8 +1,15 @@
FROM python:2.7
ENV PYTHONBUFFERED 1
RUN mkdir -p /code/log /code/test_case /code/upload
RUN chown -R nobody:nogroup /code/log /code/test_case /code/upload
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -i http://pypi.douban.com/simple -r requirements.txt --trusted-host pypi.douban.com
EXPOSE 8010
CMD supervisord
RUN rm /etc/apt/sources.list
ADD sources.list /etc/apt/
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get -y install nodejs
ADD gunicorn.conf /etc
ADD supervisord.conf /etc
ADD task_queue.conf /etc
CMD bash /code/dockerfiles/oj_web_server/run.sh

View File

@ -1,16 +1,12 @@
[program:gunicorn]
command=gunicorn oj.wsgi:application -b 0.0.0.0:8080 --reload
directory=/code/
user=root
user=nobody
numprocs=1
stdout_logfile=/code/log/gunicorn.log
stderr_logfile=/code/log/gunicorn.log
autostart=true
autorestart=true
startsecs=5
stopwaitsecs = 6
killasgroup=true

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
find /code -name "*.pyc" -delete
python -m compileall /code
exec supervisord

View File

@ -1,26 +1,21 @@
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
file=/tmp/supervisor.sock
[supervisord]
logfile=/code/log/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=info ; info, debug, warn, trace
pidfile=/code/log/supervisord.pid ; pidfile location
nodaemon=true ; run supervisord as a daemon
minfds=1024 ; number of startup file descriptors
minprocs=200 ; number of process descriptors
user=root ; default user
childlogdir=/code/log/ ; where child log files will live
logfile=/code/log/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/code/log/supervisord.pid
nodaemon=true
minfds=1024
minprocs=200
user=nobody
childlogdir=/code/log/
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use unix:// schem for a unix sockets.
serverurl=unix:///tmp/supervisor.sock
[include]
files=gunicorn.conf task_queue.conf

View File

@ -1,16 +1,12 @@
[program:task_queue]
command=python manage.py celeryd -B -l DEBUG
directory=/code/
user=root
user=nobody
numprocs=1
stdout_logfile=/code/log/task_queue.log
stderr_logfile=/code/log/task_queue.log
autostart=true
autorestart=true
startsecs=5
stopwaitsecs = 6
killasgroup=true