bundles/paperless: fix config for static directory

This commit is contained in:
Franzi 2024-02-17 04:44:29 +01:00
parent 72f756a686
commit 26ee966bd6
Signed by: kunsi
GPG key ID: 12E3D2136B818350
6 changed files with 38 additions and 53 deletions

View file

@ -11,14 +11,14 @@ PAPERLESS_DBSSLMODE=disable
PAPERLESS_CONSUMPTION_DIR=/mnt/paperless/consume
PAPERLESS_DATA_DIR=/mnt/paperless/data
PAPERLESS_MEDIA_ROOT=/mnt/paperless/media
PAPERLESS_STATICDIR=/opt/paperless/static
PAPERLESS_STATICDIR=/opt/paperless/src/paperless-ngx/static
PAPERLESS_FILENAME_FORMAT={created_year}/{created_month}/{correspondent}/{asn}_{title}
# Security and hosting
PAPERLESS_SECRET_KEY=${repo.vault.random_bytes_as_base64_for(f'{node.name} paperless secret key')}
PAPERLESS_ALLOWED_HOSTS=${node.metadata.get('nginx/vhosts/paperless/domain', '127.0.0.1')}
PAPERLESS_CORS_ALLOWED_HOSTS=http://${node.metadata.get('nginx/vhosts/paperless/domain', '127.0.0.1')},https://${node.metadata.get('nginx/vhosts/paperless/domain', '127.0.0.1')}
PAPERLESS_ALLOWED_HOSTS=${node.metadata.get('paperless/domain')}
PAPERLESS_CORS_ALLOWED_HOSTS=http://${node.metadata.get('paperless/domain')},https://${node.metadata.get('paperless/domain')}
#PAPERLESS_FORCE_SCRIPT_NAME=
#PAPERLESS_STATIC_URL=/static/
#PAPERLESS_AUTO_LOGIN_USERNAME=

View file

@ -7,11 +7,6 @@ users['paperless'] = {
directories['/opt/paperless'] = {}
directories['/opt/paperless/static'] = {
'owner': 'paperless',
}
files['/opt/paperless/paperless.conf'] = {
'content_type': 'mako',
'triggers': {
@ -73,22 +68,6 @@ actions['paperless_migrate_database'] = {
'postgres_db:paperless',
},
}
actions['paperless_collectstatic'] = {
'command': ' && '.join([
'cd /opt/paperless/src/paperless-ngx/src',
'sudo -Hu paperless PAPERLESS_CONFIGURATION_PATH=/opt/paperless/paperless.conf /opt/paperless/venv/bin/python manage.py collectstatic',
]),
'triggered': True,
'needs': {
# /mnt/paperless is NOT created by this bundle.
'action:paperless_install',
'directory:/mnt/paperless',
'directory:/opt/paperless/static',
'file:/opt/paperless/paperless.conf',
'user:paperless',
'postgres_db:paperless',
},
}
for worker in workers:
files[f'/etc/systemd/system/paperless-{worker}.service'] = {
@ -109,7 +88,6 @@ for worker in workers:
'needs': {
'action:paperless_install',
'action:paperless_migrate_database',
'action:paperless_collectstatic',
f'file:/usr/local/lib/systemd/system/paperless-{worker}.service',
},
}

View file

@ -79,3 +79,36 @@ def icinga_check_for_new_release(metadata):
},
},
}
@metadata_reactor.provides(
'nginx/vhosts/paperless',
)
def nginx(metadata):
if not node.has_bundle('nginx'):
raise DoNotRunAgain
return {
'nginx': {
'vhosts': {
'paperless': {
'domain': metadata.get('paperless/domain'),
'locations': {
'/': {
'target': 'http://127.0.0.1:22070',
'websockets': True,
'proxy_set_header': {
'X-Forwarded-Host': '$server_name',
},
},
'/static/': {
'alias': '/opt/paperless/src/paperless-ngx/static/',
},
},
'max_body_size': '100M',
'website_check_path': '/accounts/login/',
'website_check_string': 'Paperless-ngx',
},
},
},
}

View file

@ -1,3 +0,0 @@
location /static/ {
alias /opt/paperless/static/;
}

View file

@ -49,22 +49,12 @@ nodes['home.paperless-sophie'] = {
'nginx': {
'vhosts': {
'paperless': {
'domain': 'paperless-sophie.home.kunbox.net',
'ssl': '_.home.kunbox.net',
'locations': {
'/': {
'target': 'http://127.0.0.1:22070',
'websockets': True,
'proxy_set_header': {
'X-Forwarded-Host': '$server_name',
},
},
},
'extras': True,
},
},
},
'paperless': {
'domain': 'paperless-sophie.home.kunbox.net',
'version': 'ng-1.4.4',
'timezone': 'Europe/Berlin',
},

View file

@ -36,25 +36,12 @@ nodes['home.paperless'] = {
'nginx': {
'vhosts': {
'paperless': {
'domain': 'paperless.home.kunbox.net',
'ssl': '_.home.kunbox.net',
'locations': {
'/': {
'target': 'http://127.0.0.1:22070',
'websockets': True,
'proxy_set_header': {
'X-Forwarded-Host': '$server_name',
},
},
'/static/': {
'alias': '/opt/paperless/static/',
},
},
'max_body_size': '100M',
},
},
},
'paperless': {
'domain': 'paperless.home.kunbox.net',
'version': 'v2.5.3',
'timezone': 'Europe/Berlin',
},