docker-compose 部署

DockerFile

# Dockerfile template for python2 uwsgi
# debian版本需要与apt_get中的源一致

FROM python:2.7.16-jessie

# upgrade & install required packages
RUN echo "deb http://apt.x.netease.com:8660/debian/ jessie main non-free contrib\n \
deb-src http://apt.x.netease.com:8660/debian/ jessie main non-free contrib\n \
deb http://apt.x.netease.com:8660/debian-security/ jessie/updates main non-free contrib\n \
deb-src http://apt.x.netease.com:8660/debian-security/ jessie/updates main non-free contrib" > /etc/apt/sources.list

RUN apt-get update && apt-get upgrade -y

#-version-2019-06-03

ENV TZ Asia/Hong_Kong
ENV LANG C.UTF-8
ENV HOMEDIR /home/projects/igor
ENV PROJ_SRC $HOMEDIR/src
ENV PROJ_ETC $HOMEDIR/etc
ENV PROJ_VAR $HOMEDIR/var
WORKDIR $HOMEDIR

RUN mkdir -p $HOMEDIR $PROJ_SRC $PROJ_ETC /root/.pip $HOMEDIR/.pip
RUN groupadd -r igor && useradd -r -g igor igor -s /bin/bash -d $HOMEDIR
RUN ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime
RUN echo 'igor:igor' | chpasswd

COPY ./etc/pip.conf /root/.pip/pip.conf
COPY ./etc/pip.conf $HOMEDIR/.pip/pip.conf
COPY ./etc/pydistutils.cfg /root/.pydistutils.cfg
COPY ./etc/pydistutils.cfg $HOMEDIR/.pydistutils.cfg

ENV PY_PKG_PATH /usr/local/lib/python2.7/site-packages

RUN pip install uWSGI==2.0.17.1

RUN  pip install https://nanny.netease.com/gzguxin/appinsight/archive/master.zip

COPY ./src/mumu-store-server-v2/requirements.txt $PROJ_ETC/requirements.txt
RUN sed -i '/uwsgi/Id' $PROJ_ETC/requirements.txt
RUN  pip install -r $PROJ_ETC/requirements.txt

COPY ./src/igor-runtime-module $PROJ_SRC/igor-runtime-module
COPY ./src/mumu-store-server-v2 $PROJ_SRC/mumu-store-server-v2
COPY ./etc/igor_runtime_config.py $PY_PKG_PATH/igor_runtime_config.py
COPY ./etc/igor_app_config.py $PY_PKG_PATH/igor_app_config.py

RUN pip install -e $PROJ_SRC/igor-runtime-module
RUN pip install -e $PROJ_SRC/mumu-store-server-v2

# reinstall subversion requirements
RUN grep @ $PROJ_ETC/requirements.txt > $PROJ_ETC/subversion_requirements.txt || true

RUN [ -s $PROJ_ETC/subversion_requirements.txt ] &&  pip install -Ur $PROJ_ETC/subversion_requirements.txt || true

COPY ./etc/app_uwsgi.yaml $PROJ_ETC/app_uwsgi.yaml
# 删除virtualenv以及pypy对应的行, 未来应该直接修改app_uwsgi的模板
RUN sed -i '/virtualenv/Id' $PROJ_ETC/app_uwsgi.yaml
RUN sed -i '/pypy-home/Id' $PROJ_ETC/app_uwsgi.yaml

RUN chown -R igor:igor $HOMEDIR
COPY ./src/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["uwsgi", "-y", "etc/app_uwsgi.yaml"]

docker-entrypoint.sh

#!/bin/bash

set -e

VAR_DIR=/home/projects/igor/var

# Make sure the dir has been mounted.
[ -d "$VAR_DIR" ] || exit 1

# make sure the dir will create.
mkdir -pv $VAR_DIR/{log,run,scripts}
chown -R igor:igor $VAR_DIR

exec "$@"

uwsgi.yaml

uwsgi:
  master: 1
  vacuum: 1
  virtualenv: /home/projects/igor/virtualenv
  procname-prefix: mumu-store-api-45090_
  processes: 40
  uid: igor
  gid: igor
  chdir: /home/projects/igor

  
  
  wsgi: store.api_app
  
  need-app: 1
  

  lazy-apps: 1
  
  disable-logging: true
  

  logger: file:/home/projects/igor/var/log/uwsgi.log
  logger: rsyslog:psigor-log01-igor-in.i.nease.net:514,682,144
  rsyslog-split-messages: true
  

  
  http-socket: :6000
  

  
  stats: /home/projects/igor/var/run/stats.sock
  master-fifo:  /home/projects/igor/var/run/igor.fifo
  max-fd: 65535
  reload-on-rss: 256
  
  log-reopen: true
  log-slow: 1000
  buffer-size: 32768
  umask: 027
  worker-reload-mercy: 10
  enable-threads: true
  listen: 1024
  
  cheaper: 12
  cheaper-step: 4
  
  die-on-term: true
  harakiri: 30
  
  import: igorlib

你可能感兴趣的:(docker-compose 部署)