-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (33 loc) · 1.36 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
46
47
48
FROM python:3.7.2-alpine3.8
ARG root=/app
ARG version
LABEL kind=app
WORKDIR ${root}
ENV VERSION=${version} \
PYTHONPATH=${root} PREFIX=${root} \
STATIC_ROOT=/static MEDIA_ROOT=/media \
STATIC_ROOT_SOURCE=/static-source \
APP_NAME="languk.wsgi:application" APP_WORKERS="2"
RUN [ "x${VERSION}" = "x" ] && echo -e '=== build-arg "version" is required for building an image ===' && exit 1 || exit 0
RUN /usr/sbin/adduser -D -h ${root} app
COPY ./languk/requirements.txt ${root}/requirements.txt
RUN apk add --no-cache su-exec postgresql-libs libjpeg \
&& apk add --no-cache --virtual .build-deps jpeg-dev zlib-dev postgresql-dev build-base git \
&& PREFIX=/usr/local pip install -r ${root}/requirements.txt \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
apk add --no-cache --virtual .app-rundeps $runDeps \
&& apk del .build-deps
COPY docker-entrypoint.sh /usr/local/bin/
COPY ./languk/ ${root}/
RUN python -m compileall ${root} \
&& mkdir -p ${STATIC_ROOT} ${STATIC_ROOT_SOURCE} ${MEDIA_ROOT} \
&& STATIC_ROOT=${STATIC_ROOT_SOURCE} python manage.py collectstatic --no-input
ENTRYPOINT [ "docker-entrypoint.sh" ]
VOLUME [ "${STATIC_ROOT}", "${MEDIA_ROOT}" ]
EXPOSE 8000
CMD [ "gunicorn" ]