Back to basics for compressed staticfiles. x86_64 only

This commit is contained in:
Trenton Holmes 2023-10-19 19:59:06 -07:00
parent 9880f9ebc7
commit a5be8eeb18
3 changed files with 24 additions and 3 deletions

View File

@ -451,6 +451,11 @@ jobs:
name: Install Python dependencies name: Install Python dependencies
run: | run: |
pipenv --python ${{ steps.setup-python.outputs.python-version }} sync --dev pipenv --python ${{ steps.setup-python.outputs.python-version }} sync --dev
-
name: Gather info
run: |
pipenv --python ${{ steps.setup-python.outputs.python-version }} run python3 -m site
pipenv --python ${{ steps.setup-python.outputs.python-version }} run pip3 list --verbose
- -
name: Install system dependencies name: Install system dependencies
run: | run: |

View File

@ -205,6 +205,10 @@ RUN --mount=type=cache,target=/root/.cache/pip/,id=pip-cache \
&& python3 -m pip install --no-cache-dir --upgrade wheel \ && python3 -m pip install --no-cache-dir --upgrade wheel \
&& echo "Installing Python requirements" \ && echo "Installing Python requirements" \
&& python3 -m pip install --default-timeout=1000 --requirement requirements.txt \ && python3 -m pip install --default-timeout=1000 --requirement requirements.txt \
&& echo "Patching whitenoise for compression speedup" \
&& curl --fail --silent --show-error --location --output 484.patch https://github.com/evansd/whitenoise/pull/484.patch \
&& patch -d /usr/local/lib/python3.11/site-packages --verbose -p2 < 484.patch \
&& rm 484.patch \
&& echo "Installing NLTK data" \ && echo "Installing NLTK data" \
&& python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" snowball_data \ && python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" snowball_data \
&& python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" stopwords \ && python3 -W ignore::RuntimeWarning -m nltk.downloader -d "/usr/share/nltk_data" stopwords \
@ -220,10 +224,10 @@ RUN --mount=type=cache,target=/root/.cache/pip/,id=pip-cache \
&& truncate --size 0 /var/log/*log && truncate --size 0 /var/log/*log
# copy backend # copy backend
COPY ./src ./ COPY --chown=1000:1000 ./src ./
# copy frontend # copy frontend
COPY --from=compile-frontend /src/src/documents/static/frontend/ ./documents/static/frontend/ COPY --from=compile-frontend --chown=1000:1000 /src/src/documents/static/frontend/ ./documents/static/frontend/
# add users, setup scripts # add users, setup scripts
# Mount the compiled frontend to expected location # Mount the compiled frontend to expected location
@ -237,7 +241,7 @@ RUN set -eux \
&& mkdir --parents --verbose /usr/src/paperless/consume \ && mkdir --parents --verbose /usr/src/paperless/consume \
&& mkdir --parents --verbose /usr/src/paperless/export \ && mkdir --parents --verbose /usr/src/paperless/export \
&& echo "Adjusting all permissions" \ && echo "Adjusting all permissions" \
&& chown --recursive paperless:paperless /usr/src/paperless \ && chown --from root:root --changes --recursive paperless:paperless /usr/src/paperless \
&& echo "Collecting static files" \ && echo "Collecting static files" \
&& gosu paperless python3 manage.py collectstatic --clear --no-input --link \ && gosu paperless python3 manage.py collectstatic --clear --no-input --link \
&& gosu paperless python3 manage.py compilemessages && gosu paperless python3 manage.py compilemessages

View File

@ -7,6 +7,7 @@ import re
import tempfile import tempfile
from os import PathLike from os import PathLike
from pathlib import Path from pathlib import Path
from platform import machine
from typing import Final from typing import Final
from typing import Optional from typing import Optional
from typing import Union from typing import Union
@ -342,6 +343,17 @@ ASGI_APPLICATION = "paperless.asgi.application"
STATIC_URL = os.getenv("PAPERLESS_STATIC_URL", BASE_URL + "static/") STATIC_URL = os.getenv("PAPERLESS_STATIC_URL", BASE_URL + "static/")
WHITENOISE_STATIC_PREFIX = "/static/" WHITENOISE_STATIC_PREFIX = "/static/"
if machine().lower() == "aarch64": # pragma: no cover
_static_backend = "django.contrib.staticfiles.storage.StaticFilesStorage"
else:
_static_backend = "whitenoise.storage.CompressedStaticFilesStorage"
STORAGES = {
"staticfiles": {
"BACKEND": _static_backend,
},
}
_CELERY_REDIS_URL, _CHANNELS_REDIS_URL = _parse_redis_url( _CELERY_REDIS_URL, _CHANNELS_REDIS_URL = _parse_redis_url(
os.getenv("PAPERLESS_REDIS", None), os.getenv("PAPERLESS_REDIS", None),
) )