Dockerfile 1.66 KB
Newer Older
1
FROM alpine:3.13 as builder
2

3
4
RUN \
    echo 'installing dependencies' && \
5
6
7
    apk add --no-cache \
    git \
    musl-dev \
8
9
    gcc \
    postgresql-dev \
10
11
12
13
14
15
16
    python3-dev \
    py3-psycopg2 \
    libldap \
    libffi-dev \
    make \
    zlib-dev \
    jpeg-dev \
Eliot Berriot's avatar
Eliot Berriot committed
17
    openldap-dev \
18
19
    openssl-dev \
    cargo \
Georg Krause's avatar
Georg Krause committed
20
21
    libxml2-dev \
    libxslt-dev \
22
    && \
23
    ln -s /usr/bin/python3 /usr/bin/python
24

25
26
27
28
29
# create virtual env for next stage
RUN python -m venv /venv
# emulate activation by prefixing PATH
ENV PATH="/venv/bin:$PATH" VIRTUAL_ENV=/venv

30
RUN mkdir /requirements
Eliot Berriot's avatar
Eliot Berriot committed
31
COPY ./requirements/base.txt /requirements/base.txt
32
33
# hack around https://github.com/pypa/pip/issues/6158#issuecomment-456619072
ENV PIP_DOWNLOAD_CACHE=/noop/
34
35
RUN \
    echo 'installing pip requirements' && \
36
37
38
39
    pip3 install --upgrade pip && \
    pip3 install setuptools wheel && \
    pip3 install -r /requirements/base.txt && \
    rm -rf $PIP_DOWNLOAD_CACHE
40

41
42
43
44
ARG install_dev_deps=0
COPY ./requirements/*.txt /requirements/
RUN \
    if [ "$install_dev_deps" = "1" ] ; then echo "Installing dev dependencies" && pip3 install --no-cache-dir -r /requirements/local.txt -r /requirements/test.txt ; else echo "Skipping dev deps installation" ; fi
45

46

47
FROM alpine:3.13 as build-image
48
49
50
51
52
53
54

COPY --from=builder /venv /venv
# emulate activation by prefixing PATH
ENV PATH="/venv/bin:$PATH"

RUN apk add --no-cache \
    libmagic \
55
56
57
    bash \
    gettext \
    python3 \
58
    jpeg-dev \
59
60
    ffmpeg \
    libpq \
Georg Krause's avatar
Georg Krause committed
61
62
    libxml2 \
    libxslt \
63
64
65
    && \
    ln -s /usr/bin/python3 /usr/bin/python

66
67
68
69
COPY . /app
WORKDIR /app

RUN chmod 755 compose compose/django
70

71
ENTRYPOINT ["./compose/django/entrypoint.sh"]
72
CMD ["./compose/django/server.sh"]