Dockerfile: Python2.7+Flask+Gunicorn
FROM python:2.7-alpine3.6
RUN apk --no-cache add --virtual .myapp-build-deps \
linux-headers \
build-base \
musl-dev \
python-dev \
libpq \
pcre-dev \
git \
openssh
# for pip install from git repos.
COPY ./myapp-deploy.pem /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa
RUN /bin/echo -e "Host *\n\tStrictHostKeyChecking no" >> /root/.ssh/config
COPY ./requirements.txt /tmp/myapp.requirements.txt
RUN pip install --no-cache-dir -r /tmp/myapp.requirements.txt
# RUN apk del .myapp-build-deps
# Web app source code
COPY . /usr/share/myapp
WORKDIR /usr/share/myapp
ENV APP_ENV=prod
ENV FLASK_APP=myapp/application.py
CMD [ \
"gunicorn", \
"--bind=0.0.0.0:8000", \
"--worker-class=gthread", \
"--workers=5", \
"--threads=6", \
"--access-logfile=-", \
"myapp.application:app" \
]