diff --git a/Dockerfile.production b/Dockerfile.production index 604adae..5c70c4c 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,23 +1,46 @@ -From debian:buster-slim -WORKDIR /var/www/mat2-web -COPY . /var/www/mat2-web -RUN apt-get update \ -&& apt-get install --no-install-recommends --no-install-suggests --yes \ - systemd \ - mat2 \ - uwsgi \ - uwsgi-plugin-python3 \ - nginx-light \ - python3-pip \ - python3-setuptools \ - python3-wheel \ -&& rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ -&& pip3 install -r requirements.txt \ -&& mkdir ./uploads \ -&& chown -R www-data:www-data . \ -&& cp ./config/uwsgi.config /etc/uwsgi/apps-enabled/mat2-web.ini \ -&& rm /etc/nginx/sites-enabled/default \ -&& mkdir -p /etc/nginx/sites-enabled/ \ -&& cp ./config/nginx.config /etc/nginx/sites-enabled/mat2.conf +# https://github.com/nginxinc/docker-nginx-unprivileged/blob/master/stable/buster/Dockerfile -CMD ["sh", "-c", "/etc/init.d/nginx restart; uwsgi --ini /etc/uwsgi/apps-enabled/mat2-web.ini"] \ No newline at end of file +From debian:buster-slim + +LABEL maintainer="Mat-Web Maintainer " + +WORKDIR /var/www/mat2-web + +COPY . /var/www/mat2-web + +RUN set -x \ + && addgroup --system --gid 101 nginx \ + && adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx \ + && apt-get update \ + && apt-get install --no-install-recommends --no-install-suggests -y \ + gnupg1 \ + ca-certificates \ + nginx \ + gettext-base \ + systemd \ + mat2 \ + uwsgi \ + uwsgi-plugin-python3 \ + python3-pip \ + python3-setuptools \ + python3-wheel \ + && pip3 install -r requirements.txt \ + && rm /etc/nginx/sites-enabled/default /etc/nginx/nginx.conf \ + && cp ./config/nginx-default.conf /etc/nginx/sites-enabled/default \ + && cp ./config/nginx.conf /etc/nginx/nginx.conf \ + && cp ./config/uwsgi.config /etc/uwsgi/apps-enabled/mat2-web.ini \ + && chown 101:101 /etc/uwsgi/apps-enabled/mat2-web.ini \ + && mkdir -p /var/cache/nginx \ + && chown -R 101:0 /var/cache/nginx \ + && chmod -R g+w /var/cache/nginx \ + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ + && mkdir ./uploads \ + && chown -R nginx:nginx . + +STOPSIGNAL SIGTERM + +USER 101 + +CMD ["sh", "-c", "nginx; uwsgi --ini /etc/uwsgi/apps-enabled/mat2-web.ini;"] \ No newline at end of file diff --git a/config/nginx.config b/config/nginx-default.conf similarity index 79% rename from config/nginx.config rename to config/nginx-default.conf index b519ee7..fd3e2f1 100644 --- a/config/nginx.config +++ b/config/nginx-default.conf @@ -1,7 +1,7 @@ server { server_name _; - listen 80 default_server; - listen [::]:80 default_server; + listen 8080 default_server; + listen [::]:8080 default_server; client_max_body_size 20M; root /var/www/mat2-web; diff --git a/config/nginx.conf b/config/nginx.conf new file mode 100644 index 0000000..3daac64 --- /dev/null +++ b/config/nginx.conf @@ -0,0 +1,69 @@ +user nginx; +worker_processes auto; +pid /tmp/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; + + proxy_temp_path /tmp/proxy_temp; + client_body_temp_path /tmp/client_temp; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + scgi_temp_path /tmp/scgi_temp; +}