From e53ea9a05167ac9b93594bb1335cae1f2a0afe1f Mon Sep 17 00:00:00 2001 From: Jan Friedli Date: Sat, 28 Mar 2020 15:17:45 +0100 Subject: [PATCH] use tmpfs for file storage --- Dockerfile.production | 5 ++--- README.md | 7 +++++++ config/nginx-default.conf | 2 +- config/uwsgi.config | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Dockerfile.production b/Dockerfile.production index 5c70c4c..ae37e23 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -30,14 +30,13 @@ RUN set -x \ && 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 \ + && 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 . + && chown -R nginx:nginx . STOPSIGNAL SIGTERM diff --git a/README.md b/README.md index 44ec789..16990a4 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,13 @@ and `Dockerfile.production` is used for production deployments. You can find the automated docker builds in the registry of this repository: https://0xacab.org/jvoisin/mat2-web/container_registry +### Building the production image +Build command: `docker build -f Dockerfile.production -t mat-web .` + +Run it: ` docker run -ti -p8181:8080 --read-only --tmpfs /tmp --tmpfs=/var/www/mat2-web/uploads mat-web:latest` + +This does mount the upload folder as tmpfs and servers the app on `localhost:8181` + # Configuration The default settings from `main.py` may be overridden by adding a `config.py` diff --git a/config/nginx-default.conf b/config/nginx-default.conf index fd3e2f1..52c2fe2 100644 --- a/config/nginx-default.conf +++ b/config/nginx-default.conf @@ -9,6 +9,6 @@ server { location / { try_files $uri @yourapplication; } location @yourapplication { include uwsgi_params; - uwsgi_pass unix:/var/www/mat2-web/mat2-web.sock; + uwsgi_pass unix:/tmp/uwsgi.sock; } } diff --git a/config/uwsgi.config b/config/uwsgi.config index 177ddaf..9b46181 100644 --- a/config/uwsgi.config +++ b/config/uwsgi.config @@ -13,7 +13,7 @@ gid = www-data harakiri = 30 die-on-term = true -socket = mat2-web.sock +socket = /tmp/uwsgi.sock chmod-socket = 774 plugins = python3