summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Friedli2020-03-28 15:17:45 +0100
committerJan Friedli2020-05-09 21:21:47 +0200
commite53ea9a05167ac9b93594bb1335cae1f2a0afe1f (patch)
tree4480bc6e0e9d2121287f92e569f8f41db913fe14
parent40d4fdad9e8ce5872adf18100196fa77044642c1 (diff)
use tmpfs for file storage
-rw-r--r--Dockerfile.production5
-rw-r--r--README.md7
-rw-r--r--config/nginx-default.conf2
-rw-r--r--config/uwsgi.config2
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 \
30 && cp ./config/nginx.conf /etc/nginx/nginx.conf \ 30 && cp ./config/nginx.conf /etc/nginx/nginx.conf \
31 && cp ./config/uwsgi.config /etc/uwsgi/apps-enabled/mat2-web.ini \ 31 && cp ./config/uwsgi.config /etc/uwsgi/apps-enabled/mat2-web.ini \
32 && chown 101:101 /etc/uwsgi/apps-enabled/mat2-web.ini \ 32 && chown 101:101 /etc/uwsgi/apps-enabled/mat2-web.ini \
33 && mkdir -p /var/cache/nginx \ 33 && mkdir -p /var/cache/nginx \
34 && chown -R 101:0 /var/cache/nginx \ 34 && chown -R 101:0 /var/cache/nginx \
35 && chmod -R g+w /var/cache/nginx \ 35 && chmod -R g+w /var/cache/nginx \
36 && ln -sf /dev/stdout /var/log/nginx/access.log \ 36 && ln -sf /dev/stdout /var/log/nginx/access.log \
37 && ln -sf /dev/stderr /var/log/nginx/error.log \ 37 && ln -sf /dev/stderr /var/log/nginx/error.log \
38 && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \ 38 && rm -rf /var/cache/apt/* /var/lib/apt/lists/* \
39 && mkdir ./uploads \ 39 && chown -R nginx:nginx .
40 && chown -R nginx:nginx .
41 40
42STOPSIGNAL SIGTERM 41STOPSIGNAL SIGTERM
43 42
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.
202You can find the automated docker builds in the registry of this 202You can find the automated docker builds in the registry of this
203repository: https://0xacab.org/jvoisin/mat2-web/container_registry 203repository: https://0xacab.org/jvoisin/mat2-web/container_registry
204 204
205### Building the production image
206Build command: `docker build -f Dockerfile.production -t mat-web .`
207
208Run it: ` docker run -ti -p8181:8080 --read-only --tmpfs /tmp --tmpfs=/var/www/mat2-web/uploads mat-web:latest`
209
210This does mount the upload folder as tmpfs and servers the app on `localhost:8181`
211
205# Configuration 212# Configuration
206 213
207The default settings from `main.py` may be overridden by adding a `config.py` 214The 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 {
9 location / { try_files $uri @yourapplication; } 9 location / { try_files $uri @yourapplication; }
10 location @yourapplication { 10 location @yourapplication {
11 include uwsgi_params; 11 include uwsgi_params;
12 uwsgi_pass unix:/var/www/mat2-web/mat2-web.sock; 12 uwsgi_pass unix:/tmp/uwsgi.sock;
13 } 13 }
14} 14}
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
13harakiri = 30 13harakiri = 30
14die-on-term = true 14die-on-term = true
15 15
16socket = mat2-web.sock 16socket = /tmp/uwsgi.sock
17chmod-socket = 774 17chmod-socket = 774
18plugins = python3 18plugins = python3
19 19