diff options
| author | Jan Friedli | 2020-03-28 13:45:19 +0100 |
|---|---|---|
| committer | Jan Friedli | 2020-05-09 21:16:09 +0200 |
| commit | 40d4fdad9e8ce5872adf18100196fa77044642c1 (patch) | |
| tree | 4028f88ecb40d7ad5c50a7eed5434f4355d3e682 /Dockerfile.production | |
| parent | 853ace7d83424f85d903f6ffe2352bf41f86b7ce (diff) | |
use a non root user to start nginx
Diffstat (limited to 'Dockerfile.production')
| -rw-r--r-- | Dockerfile.production | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/Dockerfile.production b/Dockerfile.production index 604adae..5c70c4c 100644 --- a/Dockerfile.production +++ b/Dockerfile.production | |||
| @@ -1,23 +1,46 @@ | |||
| 1 | # https://github.com/nginxinc/docker-nginx-unprivileged/blob/master/stable/buster/Dockerfile | ||
| 2 | |||
| 1 | From debian:buster-slim | 3 | From debian:buster-slim |
| 4 | |||
| 5 | LABEL maintainer="Mat-Web Maintainer <jan.friedli@immerda.ch>" | ||
| 6 | |||
| 2 | WORKDIR /var/www/mat2-web | 7 | WORKDIR /var/www/mat2-web |
| 8 | |||
| 3 | COPY . /var/www/mat2-web | 9 | COPY . /var/www/mat2-web |
| 4 | RUN apt-get update \ | ||
| 5 | && apt-get install --no-install-recommends --no-install-suggests --yes \ | ||
| 6 | systemd \ | ||
| 7 | mat2 \ | ||
| 8 | uwsgi \ | ||
| 9 | uwsgi-plugin-python3 \ | ||
| 10 | nginx-light \ | ||
| 11 | python3-pip \ | ||
| 12 | python3-setuptools \ | ||
| 13 | python3-wheel \ | ||
| 14 | && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ | ||
| 15 | && pip3 install -r requirements.txt \ | ||
| 16 | && mkdir ./uploads \ | ||
| 17 | && chown -R www-data:www-data . \ | ||
| 18 | && cp ./config/uwsgi.config /etc/uwsgi/apps-enabled/mat2-web.ini \ | ||
| 19 | && rm /etc/nginx/sites-enabled/default \ | ||
| 20 | && mkdir -p /etc/nginx/sites-enabled/ \ | ||
| 21 | && cp ./config/nginx.config /etc/nginx/sites-enabled/mat2.conf | ||
| 22 | 10 | ||
| 23 | CMD ["sh", "-c", "/etc/init.d/nginx restart; uwsgi --ini /etc/uwsgi/apps-enabled/mat2-web.ini"] \ No newline at end of file | 11 | RUN set -x \ |
| 12 | && addgroup --system --gid 101 nginx \ | ||
| 13 | && adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx \ | ||
| 14 | && apt-get update \ | ||
| 15 | && apt-get install --no-install-recommends --no-install-suggests -y \ | ||
| 16 | gnupg1 \ | ||
| 17 | ca-certificates \ | ||
| 18 | nginx \ | ||
| 19 | gettext-base \ | ||
| 20 | systemd \ | ||
| 21 | mat2 \ | ||
| 22 | uwsgi \ | ||
| 23 | uwsgi-plugin-python3 \ | ||
| 24 | python3-pip \ | ||
| 25 | python3-setuptools \ | ||
| 26 | python3-wheel \ | ||
| 27 | && pip3 install -r requirements.txt \ | ||
| 28 | && rm /etc/nginx/sites-enabled/default /etc/nginx/nginx.conf \ | ||
| 29 | && cp ./config/nginx-default.conf /etc/nginx/sites-enabled/default \ | ||
| 30 | && cp ./config/nginx.conf /etc/nginx/nginx.conf \ | ||
| 31 | && cp ./config/uwsgi.config /etc/uwsgi/apps-enabled/mat2-web.ini \ | ||
| 32 | && chown 101:101 /etc/uwsgi/apps-enabled/mat2-web.ini \ | ||
| 33 | && mkdir -p /var/cache/nginx \ | ||
| 34 | && chown -R 101:0 /var/cache/nginx \ | ||
| 35 | && chmod -R g+w /var/cache/nginx \ | ||
| 36 | && ln -sf /dev/stdout /var/log/nginx/access.log \ | ||
| 37 | && ln -sf /dev/stderr /var/log/nginx/error.log \ | ||
| 38 | && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ | ||
| 39 | && mkdir ./uploads \ | ||
| 40 | && chown -R nginx:nginx . | ||
| 41 | |||
| 42 | STOPSIGNAL SIGTERM | ||
| 43 | |||
| 44 | USER 101 | ||
| 45 | |||
| 46 | CMD ["sh", "-c", "nginx; uwsgi --ini /etc/uwsgi/apps-enabled/mat2-web.ini;"] \ No newline at end of file | ||
