Created
March 28, 2016 16:41
-
-
Save satyrius/8fbebe22827b978b9df5 to your computer and use it in GitHub Desktop.
Python 2.7 minimal Docker image (with psycopg2, nginx and supervisor)
This file contains 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 debian:jessie | |
ENV PYENV_ROOT=/opt/pyenv PATH=/opt/pyenv/shims:/opt/pyenv/bin:$PATH LANG=en_US.UTF-8 | |
RUN set -x \ | |
&& echo "LANG=$LANG" > /etc/default/locale \ | |
&& echo "$LANG UTF-8" > /etc/locale.gen \ | |
&& export DEBIAN_FRONTEND=noninteractive \ | |
&& apt-get update -qq \ | |
&& apt-get install -y locales \ | |
&& apt-get install -y \ | |
libpq5 \ | |
nginx-light \ | |
&& BUILD_DEPS='build-essential curl git-core zlib1g-dev libssl-dev libbz2-dev libreadline-dev libpq-dev' \ | |
&& apt-get install -y ${BUILD_DEPS} \ | |
&& PYTHON_VERSION=2.7.11 \ | |
&& curl --silent --show-error --retry 5 https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash \ | |
&& pyenv update \ | |
&& pyenv install ${PYTHON_VERSION} && pyenv global ${PYTHON_VERSION} \ | |
&& rm -rf ${PYENV_ROOT}/plugins \ | |
&& pip install --upgrade pip && pip --version \ | |
&& pip install \ | |
psycopg2==2.6.1 \ | |
supervisor==3.2.3 \ | |
&& apt-get autoremove -y ${BUILD_DEPS} \ | |
&& 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
The key to minimify image is to remove all build dependencies in the same step. The result is 282.5 Mb
Build dependencies:
BUILD_DEPS
. And you should remove them after build.About runtime dependencies:
libpq5
is required forpsycopg2
(if you use PostgreSQL for you app);nginx-light
vsnginx-full
is 1Mb vs _50Mb_6 sj use first;supervisor
as init process for my containers, you should install it usingpip
to do not install extra system dependencies.