|
4 | 4 |
|
5 | 5 | FROM python:3.5-alpine
|
6 | 6 |
|
7 |
| -RUN addgroup -g 1001 app && \ |
8 |
| - adduser -D -u 1001 -G app -s /usr/sbin/nologin app |
| 7 | +MAINTAINER mars@mozilla.com |
| 8 | +# These are unlikely to change from version to version of the container |
| 9 | +EXPOSE 8000 |
| 10 | +CMD ["/usr/local/bin/uwsgi", "--http-auto-chunked", "--http-keepalive"] |
| 11 | + |
| 12 | +RUN addgroup -g 10001 app && adduser -D -u 10001 -G app -h /app app |
| 13 | + |
| 14 | +# uWSGI configuration |
| 15 | +ENV UWSGI_MODULE=landoapi.wsgi:app \ |
| 16 | + UWSGI_HTTP=:8000 \ |
| 17 | + UWSGI_MASTER=1 \ |
| 18 | + UWSGI_WORKERS=2 \ |
| 19 | + UWSGI_THREADS=8 \ |
| 20 | + # Disable worker memory sharing optimizations. They can cause memory leaks |
| 21 | + # and issues with packages like Sentry. |
| 22 | + # See https://discuss.newrelic.com/t/newrelic-agent-produces-system-error/43446 |
| 23 | + UWSGI_LAZY_APPS=1 \ |
| 24 | + UWSGI_WSGI_ENV_BEHAVIOR=holy \ |
| 25 | + # Make uWSGI die instead of reload when it gets SIGTERM (fixed in uWSGI 2.1) |
| 26 | + UWSGI_DIE_ON_TERM=1 \ |
| 27 | + # Check that the options we gave uWSGI are sane |
| 28 | + UWSGI_STRICT=1 \ |
| 29 | + # Die if the application threw an exception on startup |
| 30 | + UWSGI_NEED_APP=1 |
9 | 31 |
|
10 | 32 | COPY requirements.txt /requirements.txt
|
11 |
| -RUN pip install --no-cache -r /requirements.txt |
| 33 | + |
| 34 | + |
| 35 | +RUN set -ex \ |
| 36 | + && apk add --no-cache --virtual .build-deps \ |
| 37 | + gcc \ |
| 38 | + libc-dev \ |
| 39 | + musl-dev \ |
| 40 | + linux-headers \ |
| 41 | + pcre-dev \ |
| 42 | + && pip install --no-cache -r /requirements.txt \ |
| 43 | + && runDeps="$( \ |
| 44 | + scanelf --needed --nobanner --recursive /usr/local \ |
| 45 | + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ |
| 46 | + | sort -u \ |
| 47 | + | xargs -r apk info --installed \ |
| 48 | + | sort -u \ |
| 49 | + )" \ |
| 50 | + && apk add --virtual .python-rundeps $runDeps \ |
| 51 | + && apk del .build-deps |
12 | 52 |
|
13 | 53 | COPY . /app
|
14 | 54 | RUN pip install --no-cache /app
|
15 | 55 |
|
16 |
| -# run as non priviledged user |
17 | 56 | USER app
|
18 |
| - |
19 |
| -# TODO allow ops to use this as a wsgi app |
20 |
| -WORKDIR /app |
|
0 commit comments