Last active
May 22, 2018 11:35
-
-
Save Midnighter/d3b6d9c1b5c270f4f48f36b3f98446c2 to your computer and use it in GitHub Desktop.
A minimal Python 3.6 Dockerfile intended for microservices that need libc. Sets up an unprivileged user and expects the use of pipenv, gunicorn, and gevent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.6-slim | |
ENV PYTHONUNBUFFERED=1 | |
ENV APP_USER=giraffe | |
ARG UID=1000 | |
ARG GID=1000 | |
ARG CWD=/app | |
ENV PYTHONPATH=${CWD} | |
RUN groupadd --system --gid "${GID}" "${APP_USER}" \ | |
&& useradd --system --uid "${UID}" --gid "${APP_USER}" "${APP_USER}" | |
WORKDIR "${CWD}" | |
COPY . "${CWD}/" | |
RUN chown -R "${APP_USER}:${APP_USER}" "${CWD}" | |
# `g++` is required for building `gevent` but all build dependencies are | |
# later removed again. | |
RUN apt-get update \ | |
&& apt-get install --yes --no-install-recommends \ | |
g++ \ | |
&& pip install --upgrade pip setuptools wheel pipenv \ | |
&& pipenv install --dev --system --deploy \ | |
&& rm -rf /root/.cache/pip \ | |
&& apt-get purge --yes g++ \ | |
&& apt-get autoremove --yes \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment