diff --git a/.python-version b/.python-version index 84691ddea..eee6392d5 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.8.15 +3.8.16 diff --git a/Dockerfile b/Dockerfile index 95cd9d95f..7cf1e8d00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,12 @@ # syntax=docker/dockerfile:1.4 # https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md +# Stage: compile-frontend +# Purpose: Compiles the frontend +# Notes: +# - Does NPM stuff with Typescript and such FROM --platform=$BUILDPLATFORM node:16-bullseye-slim AS compile-frontend -# This stage compiles the frontend -# This stage runs once for the native platform, as the outputs are not -# dependent on target arch -# Inputs: None - COPY ./src-ui /src/src-ui WORKDIR /src/src-ui @@ -17,15 +16,13 @@ RUN set -eux \ RUN set -eux \ && ./node_modules/.bin/ng build --configuration production +# Stage: pipenv-base +# Purpose: Generates a requirements.txt file for building +# Comments: +# - pipenv dependencies are not left in the final image +# - pipenv can't touch the final image somehow FROM --platform=$BUILDPLATFORM python:3.9-slim-bullseye as pipenv-base -# This stage generates the requirements.txt file using pipenv -# This stage runs once for the native platform, as the outputs are not -# dependent on target arch -# This way, pipenv dependencies are not left in the final image -# nor can pipenv mess up the final image somehow -# Inputs: None - WORKDIR /usr/src/pipenv COPY Pipfile* ./ @@ -36,6 +33,10 @@ RUN set -eux \ && echo "Generating requirement.txt" \ && pipenv requirements > requirements.txt +# Stage: main-app +# Purpose: The final image +# Comments: +# - Don't leave anything extra in here FROM python:3.9-slim-bullseye as main-app LABEL org.opencontainers.image.authors="paperless-ngx team " diff --git a/Pipfile b/Pipfile index 9d2e86112..09065956b 100644 --- a/Pipfile +++ b/Pipfile @@ -12,6 +12,7 @@ name = "piwheels" dateparser = "~=1.1" django = "~=4.1" django-cors-headers = "*" +django-compression-middleware = "*" django-extensions = "*" django-filter = "~=22.1" djangorestframework = "~=3.14" @@ -53,21 +54,18 @@ nltk = "*" pdf2image = "*" flower = "*" bleach = "*" - # # Packages locked due to issues (try to check if these are fixed in a release every so often) # - # Pin this until piwheels is building 1.9 (see https://www.piwheels.org/project/scipy/) scipy = "==1.8.1" - # Newer versions aren't builting yet (see https://www.piwheels.org/project/cryptography/) cryptography = "==38.0.1" - # Locked version until https://github.com/django/channels_redis/issues/332 # is resolved channels-redis = "==3.4.1" + [dev-packages] coveralls = "*" factory-boy = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 93253a8d4..a161f9d82 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "5d6da0ede3fc7dd05c9a1d836bf8786285b10b6134e763d06ee90d6e1ccb2be7" + "sha256": "d70848276d3ac35fa361c15ac2d634344cdb08618790502669eee209fc16fa00" }, "pipfile-spec": 6, "requires": {}, @@ -117,6 +117,93 @@ "index": "pypi", "version": "==5.0.1" }, + "brotli": { + "hashes": [ + "sha256:02177603aaca36e1fd21b091cb742bb3b305a569e2402f1ca38af471777fb019", + "sha256:11d3283d89af7033236fa4e73ec2cbe743d4f6a81d41bd234f24bf63dde979df", + "sha256:12effe280b8ebfd389022aa65114e30407540ccb89b177d3fbc9a4f177c4bd5d", + "sha256:160c78292e98d21e73a4cc7f76a234390e516afcd982fa17e1422f7c6a9ce9c8", + "sha256:16d528a45c2e1909c2798f27f7bf0a3feec1dc9e50948e738b961618e38b6a7b", + "sha256:19598ecddd8a212aedb1ffa15763dd52a388518c4550e615aed88dc3753c0f0c", + "sha256:1c48472a6ba3b113452355b9af0a60da5c2ae60477f8feda8346f8fd48e3e87c", + "sha256:268fe94547ba25b58ebc724680609c8ee3e5a843202e9a381f6f9c5e8bdb5c70", + "sha256:269a5743a393c65db46a7bb982644c67ecba4b8d91b392403ad8a861ba6f495f", + "sha256:26d168aac4aaec9a4394221240e8a5436b5634adc3cd1cdf637f6645cecbf181", + "sha256:29d1d350178e5225397e28ea1b7aca3648fcbab546d20e7475805437bfb0a130", + "sha256:2aad0e0baa04517741c9bb5b07586c642302e5fb3e75319cb62087bd0995ab19", + "sha256:3148362937217b7072cf80a2dcc007f09bb5ecb96dae4617316638194113d5be", + "sha256:330e3f10cd01da535c70d09c4283ba2df5fb78e915bea0a28becad6e2ac010be", + "sha256:336b40348269f9b91268378de5ff44dc6fbaa2268194f85177b53463d313842a", + "sha256:3496fc835370da351d37cada4cf744039616a6db7d13c430035e901443a34daa", + "sha256:35a3edbe18e876e596553c4007a087f8bcfd538f19bc116917b3c7522fca0429", + "sha256:3b78a24b5fd13c03ee2b7b86290ed20efdc95da75a3557cc06811764d5ad1126", + "sha256:3b8b09a16a1950b9ef495a0f8b9d0a87599a9d1f179e2d4ac014b2ec831f87e7", + "sha256:3c1306004d49b84bd0c4f90457c6f57ad109f5cc6067a9664e12b7b79a9948ad", + "sha256:3ffaadcaeafe9d30a7e4e1e97ad727e4f5610b9fa2f7551998471e3736738679", + "sha256:40d15c79f42e0a2c72892bf407979febd9cf91f36f495ffb333d1d04cebb34e4", + "sha256:44bb8ff420c1d19d91d79d8c3574b8954288bdff0273bf788954064d260d7ab0", + "sha256:4688c1e42968ba52e57d8670ad2306fe92e0169c6f3af0089be75bbac0c64a3b", + "sha256:495ba7e49c2db22b046a53b469bbecea802efce200dffb69b93dd47397edc9b6", + "sha256:4d1b810aa0ed773f81dceda2cc7b403d01057458730e309856356d4ef4188438", + "sha256:503fa6af7da9f4b5780bb7e4cbe0c639b010f12be85d02c99452825dd0feef3f", + "sha256:56d027eace784738457437df7331965473f2c0da2c70e1a1f6fdbae5402e0389", + "sha256:5913a1177fc36e30fcf6dc868ce23b0453952c78c04c266d3149b3d39e1410d6", + "sha256:5b6ef7d9f9c38292df3690fe3e302b5b530999fa90014853dcd0d6902fb59f26", + "sha256:5bf37a08493232fbb0f8229f1824b366c2fc1d02d64e7e918af40acd15f3e337", + "sha256:5cb1e18167792d7d21e21365d7650b72d5081ed476123ff7b8cac7f45189c0c7", + "sha256:61a7ee1f13ab913897dac7da44a73c6d44d48a4adff42a5701e3239791c96e14", + "sha256:622a231b08899c864eb87e85f81c75e7b9ce05b001e59bbfbf43d4a71f5f32b2", + "sha256:68715970f16b6e92c574c30747c95cf8cf62804569647386ff032195dc89a430", + "sha256:6b2ae9f5f67f89aade1fab0f7fd8f2832501311c363a21579d02defa844d9296", + "sha256:6c772d6c0a79ac0f414a9f8947cc407e119b8598de7621f39cacadae3cf57d12", + "sha256:6d847b14f7ea89f6ad3c9e3901d1bc4835f6b390a9c71df999b0162d9bb1e20f", + "sha256:73fd30d4ce0ea48010564ccee1a26bfe39323fde05cb34b5863455629db61dc7", + "sha256:76ffebb907bec09ff511bb3acc077695e2c32bc2142819491579a695f77ffd4d", + "sha256:7bbff90b63328013e1e8cb50650ae0b9bac54ffb4be6104378490193cd60f85a", + "sha256:7cb81373984cc0e4682f31bc3d6be9026006d96eecd07ea49aafb06897746452", + "sha256:7ee83d3e3a024a9618e5be64648d6d11c37047ac48adff25f12fa4226cf23d1c", + "sha256:854c33dad5ba0fbd6ab69185fec8dab89e13cda6b7d191ba111987df74f38761", + "sha256:85f7912459c67eaab2fb854ed2bc1cc25772b300545fe7ed2dc03954da638649", + "sha256:87fdccbb6bb589095f413b1e05734ba492c962b4a45a13ff3408fa44ffe6479b", + "sha256:88c63a1b55f352b02c6ffd24b15ead9fc0e8bf781dbe070213039324922a2eea", + "sha256:8a674ac10e0a87b683f4fa2b6fa41090edfd686a6524bd8dedbd6138b309175c", + "sha256:8ed6a5b3d23ecc00ea02e1ed8e0ff9a08f4fc87a1f58a2530e71c0f48adf882f", + "sha256:93130612b837103e15ac3f9cbacb4613f9e348b58b3aad53721d92e57f96d46a", + "sha256:9744a863b489c79a73aba014df554b0e7a0fc44ef3f8a0ef2a52919c7d155031", + "sha256:9749a124280a0ada4187a6cfd1ffd35c350fb3af79c706589d98e088c5044267", + "sha256:97f715cf371b16ac88b8c19da00029804e20e25f30d80203417255d239f228b5", + "sha256:9bf919756d25e4114ace16a8ce91eb340eb57a08e2c6950c3cebcbe3dff2a5e7", + "sha256:9d12cf2851759b8de8ca5fde36a59c08210a97ffca0eb94c532ce7b17c6a3d1d", + "sha256:9ed4c92a0665002ff8ea852353aeb60d9141eb04109e88928026d3c8a9e5433c", + "sha256:a72661af47119a80d82fa583b554095308d6a4c356b2a554fdc2799bc19f2a43", + "sha256:afde17ae04d90fbe53afb628f7f2d4ca022797aa093e809de5c3cf276f61bbfa", + "sha256:b1375b5d17d6145c798661b67e4ae9d5496920d9265e2f00f1c2c0b5ae91fbde", + "sha256:b336c5e9cf03c7be40c47b5fd694c43c9f1358a80ba384a21969e0b4e66a9b17", + "sha256:b3523f51818e8f16599613edddb1ff924eeb4b53ab7e7197f85cbc321cdca32f", + "sha256:b43775532a5904bc938f9c15b77c613cb6ad6fb30990f3b0afaea82797a402d8", + "sha256:b663f1e02de5d0573610756398e44c130add0eb9a3fc912a09665332942a2efb", + "sha256:b83bb06a0192cccf1eb8d0a28672a1b79c74c3a8a5f2619625aeb6f28b3a82bb", + "sha256:ba72d37e2a924717990f4d7482e8ac88e2ef43fb95491eb6e0d124d77d2a150d", + "sha256:c2415d9d082152460f2bd4e382a1e85aed233abc92db5a3880da2257dc7daf7b", + "sha256:c83aa123d56f2e060644427a882a36b3c12db93727ad7a7b9efd7d7f3e9cc2c4", + "sha256:c8e521a0ce7cf690ca84b8cc2272ddaf9d8a50294fd086da67e517439614c755", + "sha256:cab1b5964b39607a66adbba01f1c12df2e55ac36c81ec6ed44f2fca44178bf1a", + "sha256:cb02ed34557afde2d2da68194d12f5719ee96cfb2eacc886352cb73e3808fc5d", + "sha256:cc0283a406774f465fb45ec7efb66857c09ffefbe49ec20b7882eff6d3c86d3a", + "sha256:cfc391f4429ee0a9370aa93d812a52e1fee0f37a81861f4fdd1f4fb28e8547c3", + "sha256:db844eb158a87ccab83e868a762ea8024ae27337fc7ddcbfcddd157f841fdfe7", + "sha256:defed7ea5f218a9f2336301e6fd379f55c655bea65ba2476346340a0ce6f74a1", + "sha256:e16eb9541f3dd1a3e92b89005e37b1257b157b7256df0e36bd7b33b50be73bcb", + "sha256:e1abbeef02962596548382e393f56e4c94acd286bd0c5afba756cffc33670e8a", + "sha256:e23281b9a08ec338469268f98f194658abfb13658ee98e2b7f85ee9dd06caa91", + "sha256:e2d9e1cbc1b25e22000328702b014227737756f4b5bf5c485ac1d8091ada078b", + "sha256:e48f4234f2469ed012a98f4b7874e7f7e173c167bed4934912a29e03167cf6b1", + "sha256:e4c4e92c14a57c9bd4cb4be678c25369bf7a092d55fd0866f759e425b9660806", + "sha256:ec1947eabbaf8e0531e8e899fc1d9876c179fc518989461f5d24e2223395a9e3", + "sha256:f909bbbc433048b499cb9db9e713b5d8d949e8c109a2a548502fb9aa8630f0b1" + ], + "version": "==1.0.9" + }, "celery": { "extras": [ "redis" @@ -353,6 +440,14 @@ "index": "pypi", "version": "==2.4.0" }, + "django-compression-middleware": { + "hashes": [ + "sha256:5e089b299a603f73254a495bf60d82eb8a7d4d636ba23dbc0ee4e4e911eee37d", + "sha256:71d4bcd09546cf88783150ac6467eb4168599534774b09b806be3017139c295b" + ], + "index": "pypi", + "version": "==0.4.2" + }, "django-cors-headers": { "hashes": [ "sha256:37e42883b5f1f2295df6b4bba96eb2417a14a03270cb24b2a07f021cd4487cf4", @@ -2003,6 +2098,63 @@ ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==5.5.2" + }, + "zstandard": { + "hashes": [ + "sha256:04c298d381a3b6274b0a8001f0da0ec7819d052ad9c3b0863fe8c7f154061f76", + "sha256:0fde1c56ec118940974e726c2a27e5b54e71e16c6f81d0b4722112b91d2d9009", + "sha256:126aa8433773efad0871f624339c7984a9c43913952f77d5abeee7f95a0c0860", + "sha256:1a4fb8b4ac6772e4d656103ccaf2e43e45bd16b5da324b963d58ef360d09eb73", + "sha256:2e4812720582d0803e84aefa2ac48ce1e1e6e200ca3ce1ae2be6d410c1d637ae", + "sha256:2f01b27d0b453f07cbcff01405cdd007e71f5d6410eb01303a16ba19213e58e4", + "sha256:31d12fcd942dd8dbf52ca5f6b1bbe287f44e5d551a081a983ff3ea2082867863", + "sha256:3c927b6aa682c6d96225e1c797f4a5d0b9f777b327dea912b23471aaf5385376", + "sha256:3d5bb598963ac1f1f5b72dd006adb46ca6203e4fb7269a5b6e1f99e85b07ad38", + "sha256:401508efe02341ae681752a87e8ac9ef76df85ef1a238a7a21786a489d2c983d", + "sha256:4514b19abe6dbd36d6c5d75c54faca24b1ceb3999193c5b1f4b685abeabde3d0", + "sha256:47dfa52bed3097c705451bafd56dac26535545a987b6759fa39da1602349d7ba", + "sha256:4fa496d2d674c6e9cffc561639d17009d29adee84a27cf1e12d3c9be14aa8feb", + "sha256:55a513ec67e85abd8b8b83af8813368036f03e2d29a50fc94033504918273980", + "sha256:55b3187e0bed004533149882ef8c24e954321f3be81f8a9ceffe35099b82a0d0", + "sha256:593f96718ad906e24d6534187fdade28b611f8ed06e27ba972ba48aecec45fc6", + "sha256:5e21032efe673b887464667d09406bab6e16d96b09ad87e80859e3a20b6745b6", + "sha256:60a86b7b2b1c300779167cf595e019e61afcc0e20c4838692983a921db9006ac", + "sha256:619f9bf37cdb4c3dc9d4120d2a1003f5db9446f3618a323219f408f6a9df6725", + "sha256:660b91eca10ee1b44c47843894abe3e6cfd80e50c90dee3123befbf7ca486bd3", + "sha256:67710d220af405f5ce22712fa741d85e8b3ada7a457ea419b038469ba379837c", + "sha256:6caed86cd47ae93915d9031dc04be5283c275e1a2af2ceff33932071f3eeff4d", + "sha256:6d2182e648e79213b3881998b30225b3f4b1f3e681f1c1eaf4cacf19bde1040d", + "sha256:72758c9f785831d9d744af282d54c3e0f9db34f7eae521c33798695464993da2", + "sha256:74c2637d12eaacb503b0b06efdf55199a11b1d7c580bd3dd9dfe84cac97ef2f6", + "sha256:755020d5aeb1b10bffd93d119e7709a2a7475b6ad79c8d5226cea3f76d152ce0", + "sha256:7ccc4727300f223184520a6064c161a90b5d0283accd72d1455bcd85ec44dd0d", + "sha256:81ab21d03e3b0351847a86a0b298b297fde1e152752614138021d6d16a476ea6", + "sha256:8371217dff635cfc0220db2720fc3ce728cd47e72bb7572cca035332823dbdfc", + "sha256:876567136b0359f6581ecd892bdb4ca03a0eead0265db73206c78cff03bcdb0f", + "sha256:879411d04068bd489db57dcf6b82ffad3c5fb2a1fdd30817c566d8b7bedee442", + "sha256:898500957ae5e7f31b7271ace4e6f3625b38c0ac84e8cedde8de3a77a7fdae5e", + "sha256:8c9ca56345b0c5574db47560603de9d05f63cce5dfeb3a456eb60f3fec737ff2", + "sha256:8ec2c146e10b59c376b6bc0369929647fcd95404a503a7aa0990f21c16462248", + "sha256:8f7c68de4f362c1b2f426395fe4e05028c56d0782b2ec3ae18a5416eaf775576", + "sha256:909bdd4e19ea437eb9b45d6695d722f6f0fd9d8f493e837d70f92062b9f39faf", + "sha256:9d97c713433087ba5cee61a3e8edb54029753d45a4288ad61a176fa4718033ce", + "sha256:a65e0119ad39e855427520f7829618f78eb2824aa05e63ff19b466080cd99210", + "sha256:aa9087571729c968cd853d54b3f6e9d0ec61e45cd2c31e0eb8a0d4bdbbe6da2f", + "sha256:aef0889417eda2db000d791f9739f5cecb9ccdd45c98f82c6be531bdc67ff0f2", + "sha256:b253d0c53c8ee12c3e53d181fb9ef6ce2cd9c41cbca1c56a535e4fc8ec41e241", + "sha256:b80f6f6478f9d4ca26daee6c61584499493bf97950cfaa1a02b16bb5c2c17e70", + "sha256:be6329b5ba18ec5d32dc26181e0148e423347ed936dda48bf49fb243895d1566", + "sha256:c7560f622e3849cc8f3e999791a915addd08fafe80b47fcf3ffbda5b5151047c", + "sha256:d1a7a716bb04b1c3c4a707e38e2dee46ac544fff931e66d7ae944f3019fc55b8", + "sha256:d63b04e16df8ea21dfcedbf5a60e11cbba9d835d44cb3cbff233cfd037a916d5", + "sha256:d777d239036815e9b3a093fa9208ad314c040c26d7246617e70e23025b60083a", + "sha256:e892d3177380ec080550b56a7ffeab680af25575d291766bdd875147ba246a91", + "sha256:e9c90a44470f2999779057aeaf33461cbd8bb59d8f15e983150d10bb260e16e0", + "sha256:f097dda5d4f9b9b01b3c9fa2069f9c02929365f48f341feddf3d6b32510a2f93", + "sha256:f4ebfe03cbae821ef994b2e58e4df6a087470cc522aca502614e82a143365d45" + ], + "markers": "python_version >= '3.6'", + "version": "==0.19.0" } }, "develop": { diff --git a/docs/configuration.md b/docs/configuration.md index 1a7c8bfe9..6e210a720 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -758,6 +758,18 @@ should be a valid crontab(5) expression describing when to run. Defaults to `30 0 * * sun` or Sunday at 30 minutes past midnight. +`PAPERLESS_ENABLE_COMPRESSION=` + +: Enables compression of the responses from the webserver. + +: Defaults to 0, disabling compression. + + !!! note + + If you are using a proxy such as nginx, it is likely more efficient + to enable compression in your proxy configuration rather than + the webserver + ## Polling {#polling} `PAPERLESS_CONSUMER_POLLING=` diff --git a/src/paperless/settings.py b/src/paperless/settings.py index fa0f76a91..b94ead3b9 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -297,6 +297,10 @@ MIDDLEWARE = [ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] +# Optional to enable compression +if __get_boolean("PAPERLESS_ENABLE_COMPRESSION"): + MIDDLEWARE.insert(0, "compression_middleware.middleware.CompressionMiddleware") + ROOT_URLCONF = "paperless.urls" FORCE_SCRIPT_NAME = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME") @@ -314,7 +318,6 @@ _CELERY_REDIS_URL, _CHANNELS_REDIS_URL = _parse_redis_url( os.getenv("PAPERLESS_REDIS", None), ) -# TODO: what is this used for? TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates",