forked from kiteco/kite-python-blog-post-code
/
Dockerfile
45 lines (39 loc) · 1.2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Base Image
FROM python:3-alpine
# Set execution environment
COPY requirements /requirements
# Install dependencies from repository
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
gcc \
make \
libc-dev \
musl-dev \
linux-headers \
pcre-dev \
postgresql-dev \
jpeg-dev \
zlib-dev \
&& python -m venv --upgrade /ourenv \
&& /ourenv/bin/pip install -U pip \
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/ourenv/bin/pip install --no-cache-dir -r /requirements/dev.txt" \
&& run_deps="$( \
scanelf --needed --nobanner --recursive /ourenv \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --virtual .python-rundeps $run_deps \
&& apk del .build-deps
RUN apk add --no-cache \
curl \
openssh \
bash
RUN mkdir /code/
WORKDIR /code/
COPY . /code/
ENV IN_DOCKER=True
RUN /ourenv/bin/python manage.py migrate
RUN /ourenv/bin/python manage.py collectstatic --noinput
CMD /ourenv/bin/gunicorn config.wsgi