Dockerfile 1.33 KB
Newer Older
1 2
# This image is based on a python image.

3
# Use of stretch instead of Alpine for faster install of python packages
4
# Overall performance might be slightly better dut to the use of different lib (but with bigger image size obviously)
Florent Chehab's avatar
Florent Chehab committed
5
FROM python:3.7.2-slim-stretch
6
SHELL ["/bin/bash", "-c"]
Florent Chehab's avatar
Florent Chehab committed
7 8 9

WORKDIR /usr/src/app

10
RUN pip install --upgrade pip
11 12 13 14 15 16 17 18 19
# Installing main python packages
COPY requirements.txt /usr/src/app/requirements.txt

# python3-dev, libpq-dev and gcc  is for psycopg2-binary and uwsgi
# We do a lot of && to keep the image size small :)
RUN BUILD_DEPENCIES='libpq-dev python3-dev gcc' \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
		${BUILD_DEPENCIES} \
Florent Chehab's avatar
Florent Chehab committed
20
		make \
21 22 23
	&& pip install -r requirements.txt \
	&& apt-get remove --auto-remove -y ${BUILD_DEPENCIES} \
	&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Florent Chehab's avatar
Florent Chehab committed
24

25 26
# More python dependencies if in dev env
ARG BUILD_PRODUCTION_IMAGE="false"
Florent Chehab's avatar
Florent Chehab committed
27

28 29
COPY requirements.dev.txt /usr/src/app/requirements.dev.txt
RUN if [ "x$BUILD_PRODUCTION_IMAGE" = "xfalse" ]; then echo "building image in dev setting" && pip install -r requirements.dev.txt; else echo "building image in production setting"; fi
30 31 32 33

## Add the wait script to the image to wait for the database to be up for sure
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait
RUN chmod +x /wait