mirror of
https://0xacab.org/jvoisin/mat2-web.git
synced 2025-02-23 16:49:59 -05:00
made upload folder configurable
This commit is contained in:
parent
ac21ea756c
commit
b7cd80d155
@ -1,6 +1,6 @@
|
|||||||
# https://github.com/nginxinc/docker-nginx-unprivileged/blob/master/stable/buster/Dockerfile
|
# https://github.com/nginxinc/docker-nginx-unprivileged/blob/master/stable/buster/Dockerfile
|
||||||
|
|
||||||
From registry.0xacab.org/georg/mat2-ci-images:debian
|
From debian:buster-slim
|
||||||
|
|
||||||
LABEL maintainer="Mat-Web Co-Maintainer <jan.friedli@immerda.ch>"
|
LABEL maintainer="Mat-Web Co-Maintainer <jan.friedli@immerda.ch>"
|
||||||
|
|
||||||
@ -8,6 +8,8 @@ WORKDIR /var/www/mat2-web
|
|||||||
|
|
||||||
COPY . /var/www/mat2-web
|
COPY . /var/www/mat2-web
|
||||||
|
|
||||||
|
ENV MAT2_WEB_DOWNLOAD_FOLDER /app/upload
|
||||||
|
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
&& addgroup --system --gid 101 nginx \
|
&& 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 \
|
&& adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx \
|
||||||
@ -16,6 +18,7 @@ RUN set -x \
|
|||||||
ca-certificates \
|
ca-certificates \
|
||||||
nginx \
|
nginx \
|
||||||
systemd \
|
systemd \
|
||||||
|
mat2 \
|
||||||
uwsgi \
|
uwsgi \
|
||||||
uwsgi-plugin-python3 \
|
uwsgi-plugin-python3 \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
|
20
README.md
20
README.md
@ -47,20 +47,18 @@ Nginx is the recommended web engine, but you can also use Apache if you prefer,
|
|||||||
by copying [this file](https://0xacab.org/jvoisin/mat2-web/tree/master/config/apache2.config)
|
by copying [this file](https://0xacab.org/jvoisin/mat2-web/tree/master/config/apache2.config)
|
||||||
to your `/etc/apache2/sites-enabled/mat2-web` file.
|
to your `/etc/apache2/sites-enabled/mat2-web` file.
|
||||||
|
|
||||||
Then configure the environment variable: `MAT2_ALLOW_ORIGIN_WHITELIST=https://myhost1.org https://myhost2.org`
|
|
||||||
Note that you can add multiple hosts from which you want to accept API requests. These need to be separated by
|
|
||||||
a space.
|
|
||||||
**IMPORTANT:** The default value if the variable is not set is: `Access-Control-Allow-Origin: *`
|
|
||||||
|
|
||||||
Configure the following environment variables:
|
Configure the following environment variables:
|
||||||
|
|
||||||
|
- `MAT2_ALLOW_ORIGIN_WHITELIST=https://myhost1.org https://myhost2.org`
|
||||||
|
Note that you can add multiple hosts from which you want to accept API requests. These need to be separated by
|
||||||
|
a space. **IMPORTANT:** The default value if the variable is not set is: `Access-Control-Allow-Origin: *`
|
||||||
- `MAT2_MAX_FILES_BULK_DOWNLOAD=10` Max number of files that can be grouped for a bulk download.
|
- `MAT2_MAX_FILES_BULK_DOWNLOAD=10` Max number of files that can be grouped for a bulk download.
|
||||||
|
Note: Each file has a max file size of 16mb
|
||||||
|
|
||||||
- `MAT2_MAX_FILE_AGE_FOR_REMOVAL=900` Seconds a file in the upload folder is kept.
|
- `MAT2_MAX_FILE_AGE_FOR_REMOVAL=900` Seconds a file in the upload folder is kept.
|
||||||
After that it will be deleted. Default `15 * 60`
|
After that it will be deleted. Default `15 * 60`
|
||||||
|
- `MAT2_WEB_DOWNLOAD_FOLDER` Define the upload folder path. Defaults to: `./uploads/`
|
||||||
This specifies the max number of files that can be bulk downloaded using the api.
|
|
||||||
Note: Each file has a max file size of 16mb
|
|
||||||
|
|
||||||
Finally, restart uWSGI and your web server:
|
Finally, restart uWSGI and your web server:
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -197,7 +195,7 @@ repository: https://0xacab.org/jvoisin/mat2-web/container_registry
|
|||||||
### Building the production image
|
### Building the production image
|
||||||
Build command: `docker build -f Dockerfile.production -t mat-web .`
|
Build command: `docker build -f Dockerfile.production -t mat-web .`
|
||||||
|
|
||||||
Run it: `docker run -ti -p8181:8080 --read-only --tmpfs /tmp --tmpfs /run/uwsgi --tmpfs=/var/www/mat2-web/uploads mat-web:latest`
|
Run it: `docker run -ti -p8181:8080 --read-only --tmpfs /tmp --tmpfs /run/uwsgi --tmpfs=/app/uploads mat-web:latest`
|
||||||
|
|
||||||
This does mount the upload folder as tmpfs and servers the app on `localhost:8181`.
|
This does mount the upload folder as tmpfs and servers the app on `localhost:8181`.
|
||||||
|
|
||||||
|
2
main.py
2
main.py
@ -10,7 +10,7 @@ from flask_cors import CORS
|
|||||||
def create_app(test_config=None):
|
def create_app(test_config=None):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['SECRET_KEY'] = os.urandom(32)
|
app.config['SECRET_KEY'] = os.urandom(32)
|
||||||
app.config['UPLOAD_FOLDER'] = './uploads/'
|
app.config['UPLOAD_FOLDER'] = os.environ.get('MAT2_WEB_DOWNLOAD_FOLDER', './uploads/')
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB
|
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB
|
||||||
app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates'
|
app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates'
|
||||||
# optionally load settings from config.py
|
# optionally load settings from config.py
|
||||||
|
Loading…
x
Reference in New Issue
Block a user