From 0bc6d471faa7599186a6617fb94bf032482b7e60 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Wed, 18 Nov 2020 22:43:36 +0100 Subject: [PATCH] updated the build process, it now works on RPi as well. --- Dockerfile | 82 ----------------------------------------- Pipfile | 5 +++ Pipfile.lock | 51 +++++++++++++++++++++---- docker/local/Dockerfile | 17 ++++----- scripts/make-release.sh | 11 +++--- scripts/push-release.sh | 23 ++++++++++++ 6 files changed, 83 insertions(+), 106 deletions(-) delete mode 100644 Dockerfile create mode 100755 scripts/push-release.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 291cacdad..000000000 --- a/Dockerfile +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################### -### Front end ### -############################################################################### - -FROM node:current AS frontend - -WORKDIR /usr/src/paperless/src-ui/ - -COPY src-ui/package* ./ -RUN npm install - -COPY src-ui . -RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false --output-path dist/paperless-ui - -############################################################################### -### Back end ### -############################################################################### - -FROM ubuntu:20.04 - -WORKDIR /usr/src/paperless/ - -COPY Pipfile* ./ - -#Dependencies -RUN apt-get update \ - && DEBIAN_FRONTEND="noninteractive" apt-get -y --no-install-recommends install \ - build-essential \ - curl \ - ghostscript \ - gnupg \ - imagemagick \ - libmagic-dev \ - libpoppler-cpp-dev \ - libpq-dev \ - optipng \ - python3 \ - python3-dev \ - python3-pip \ - sudo \ - tesseract-ocr \ - tesseract-ocr-eng \ - tesseract-ocr-deu \ - tesseract-ocr-fra \ - tesseract-ocr-ita \ - tesseract-ocr-spa \ - tzdata \ - unpaper \ - && pip3 install --upgrade pipenv supervisor setuptools \ - && pipenv install --system --deploy \ - && pipenv --clear \ - && apt-get -y purge build-essential python3-pip python3-dev \ - && apt-get -y autoremove --purge \ - && rm -rf /var/lib/apt/lists/* \ - && mkdir /var/log/supervisord /var/run/supervisord - -# copy scripts -# this fixes issues with imagemagick and PDF -COPY docker/imagemagick-policy.xml /etc/ImageMagick-6/policy.xml -COPY docker/gunicorn.conf.py ./ -COPY docker/supervisord.conf /etc/supervisord.conf -COPY docker/docker-entrypoint.sh /sbin/docker-entrypoint.sh - -# copy app -COPY src/ ./src/ -COPY --from=frontend /usr/src/paperless/src-ui/dist/paperless-ui/ ./src/documents/static/frontend/ - -# add users, setup scripts -RUN addgroup --gid 1000 paperless \ - && useradd --uid 1000 --gid paperless --home-dir /usr/src/paperless paperless \ - && chown -R paperless:paperless . \ - && chmod 755 /sbin/docker-entrypoint.sh - -WORKDIR /usr/src/paperless/src/ - -RUN sudo -HEu paperless python3 manage.py collectstatic --clear --no-input - -VOLUME ["/usr/src/paperless/data", "/usr/src/paperless/media", "/usr/src/paperless/consume", "/usr/src/paperless/export"] -ENTRYPOINT ["/sbin/docker-entrypoint.sh"] -CMD ["/usr/local/bin/supervisord", "-c", "/etc/supervisord.conf"] - -LABEL maintainer="Jonas Winkler " diff --git a/Pipfile b/Pipfile index cf330f25d..66d60845b 100644 --- a/Pipfile +++ b/Pipfile @@ -3,6 +3,11 @@ url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" +[[source]] +url = "https://www.piwheels.org/simple" +verify_ssl = true +name = "piwheels" + [packages] django = "~=3.1" pillow = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 4aa573900..15a30e1c0 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d6416e6844126b09200b9839a3abdcf3c24ef5cf70052b8f134d8bc804552c17" + "sha256": "abc7e5f5a8d075d4b013ceafd06ca07f57e597f053d670f73449ba210511b114" }, "pipfile-spec": 6, "requires": {}, @@ -10,6 +10,11 @@ "name": "pypi", "url": "https://pypi.python.org/simple", "verify_ssl": true + }, + { + "name": "piwheels", + "url": "https://www.piwheels.org/simple", + "verify_ssl": true } ] }, @@ -102,6 +107,7 @@ }, "filemagic": { "hashes": [ + "sha256:b2fd77411975510e28673220c4b8868ed81b5eb5906339b6f4c233b32122d7d3", "sha256:e684359ef40820fe406f0ebc5bf8a78f89717bdb7fed688af68082d991d6dbf3" ], "index": "pypi", @@ -142,6 +148,7 @@ "langdetect": { "hashes": [ "sha256:363795ea005f1243c958e953245dac5d814fabdc025c9afa91588c5fa6b2fa83", + "sha256:ae53a024643df713274c297c0795dbfb5a16b329902f8e543e7b2d7d45f699e4", "sha256:f37495e63607865e47deed08d78f7f8e58172658216ff954b2f14671bcd87740" ], "index": "pypi", @@ -162,6 +169,7 @@ "sha256:448ebb1b3bf64c0267d6b09a7cba26b5ae61b6d2dbabff7c91b660c7eccf2bdb", "sha256:50e86c076611212ca62e5a59f518edafe0c0730f7d9195fec718da1a5c2bb1fc", "sha256:5734bdc0342aba9dfc6f04920988140fb41234db42381cf7ccba64169f9fe7ac", + "sha256:5ddd1dfa2be066595c1993165b4cae84b9866b12339d0c903db7f21a094324a3", "sha256:64324f64f90a9e4ef732be0928be853eee378fd6a01be21a0a8469c4f2682c83", "sha256:6ae6c680f3ebf1cf7ad1d7748868b39d9f900836df774c453c11c5440bc15b36", "sha256:6d7593a705d662be5bfe24111af14763016765f43cb6923ed86223f965f52387", @@ -189,7 +197,8 @@ }, "pathtools": { "hashes": [ - "sha256:7c35c5421a39bb82e58018febd90e3b6e5db34c5443aaaf742b3f33d4655f1c0" + "sha256:7c35c5421a39bb82e58018febd90e3b6e5db34c5443aaaf742b3f33d4655f1c0", + "sha256:d77d982475e87f32b82157a43b09f0a5ef3e66c1d8f3c7eb8d2580e783cd8202" ], "version": "==0.1.2" }, @@ -217,6 +226,7 @@ "sha256:2fb113757a369a6cdb189f8df3226e995acfed0a8919a72416626af1a0a71140", "sha256:4b0ef2470c4979e345e4e0cc1bbac65fda11d0d7b789dbac035e4c6ce3f98adb", "sha256:59e903ca800c8cfd1ebe482349ec7c35687b95e98cefae213e271c8c7fffa021", + "sha256:5a3342d34289715928c914ee7f389351eb37fa4857caa9297fc7948f2ed3e53d", "sha256:5abd653a23c35d980b332bc0431d39663b1709d64142e3652890df4c9b6970f6", "sha256:5f9403af9c790cc18411ea398a6950ee2def2a830ad0cfe6dc9122e6d528b302", "sha256:6b4a8fd632b4ebee28282a9fef4c341835a1aa8671e2770b6f89adc8e8c2703c", @@ -274,8 +284,10 @@ "sha256:d14b140a4439d816e3b1229a4a525df917d6ea22a0771a2a78332273fd9528a4", "sha256:d1b4ab59e02d9008efe10ceabd0b31e79519da6fb67f7d8e8977118832d0f449", "sha256:d5227b229005a696cc67676e24c214740efd90b148de5733419ac9aaba3773da", + "sha256:d9f3a909b59ac4a3ca9beb77716f4bce627276edb039a71d4e9ec4b7548536a0", "sha256:e1f57aa70d3f7cc6947fd88636a481638263ba04a742b4a37dd25c373e41491a", "sha256:e74a55f6bad0e7d3968399deb50f61f4db1926acf4a6d83beaaa7df986f48b1c", + "sha256:e7f5a465c6431c0ad8d4e69603ee3306e521a09d3c6af76a16bdb62946bdddf0", "sha256:e82aba2188b9ba309fd8e271702bd0d0fc9148ae3150532bbb474f4590039ffb", "sha256:ee69dad2c7155756ad114c02db06002f4cded41132cc51378e57aad79cc8e4f4", "sha256:f5ab93a2cb2d8338b1674be43b442a7f544a0971da062a5da774ed40587f18f5" @@ -285,7 +297,8 @@ }, "pyocr": { "hashes": [ - "sha256:fa15adc7e1cf0d345a2990495fe125a947c6e09a60ddba0256a1c14b2e603179" + "sha256:fa15adc7e1cf0d345a2990495fe125a947c6e09a60ddba0256a1c14b2e603179", + "sha256:fd602af17b6e21985669aadc058a95f343ff921e962ed4aa6520ded32e4d1301" ], "index": "pypi", "version": "==0.7.2" @@ -316,7 +329,10 @@ }, "python-levenshtein": { "hashes": [ - "sha256:033a11de5e3d19ea25c9302d11224e1a1898fe5abd23c61c7c360c25195e3eb1" + "sha256:033a11de5e3d19ea25c9302d11224e1a1898fe5abd23c61c7c360c25195e3eb1", + "sha256:15e26882728c29ccdf74cfc6ac4b49fc22c08b44d152348cb0eb1ec4f3dbf9df", + "sha256:3df5e5eb144570ecf5ad38864a2393068798328c7f05e7b167a49391d36a2db1", + "sha256:7f049b3ddc4b525bd469febafb98bf5202f789b722e0e4ccbec2ffbe8c07d7b4" ], "index": "pypi", "version": "==0.12.0" @@ -331,6 +347,7 @@ "redis": { "hashes": [ "sha256:0e7e0cfca8660dea8b7d5cd8c4f6c5e29e11f31158c0b0ae91a397f00e5a05a2", + "sha256:3f1c7f166fa6c803613eec222224848a80f5e5b9c6af3aa82461506643034a7a", "sha256:432b788c4530cfe16d8d943a09d40ca6c16149727e4afe8c2c9d5580c59d9f24" ], "index": "pypi", @@ -360,7 +377,9 @@ "sha256:749078d1eb89484db5f34b4012092ad14b327944ee7f1c4f74d6279a6e4d1884", "sha256:7913bd25f4ab274ba37bc97ad0e21c31004224ccb02765ad984eef43e04acc6c", "sha256:7a25fcbeae08f96a754b45bdc050e1fb94b95cab046bf56b016c25e9ab127b3e", + "sha256:80ef188c0e47a6c964eed71c55a73c245f8daf9f0a4a9d804e91275afb468ca4", "sha256:83d6b356e116ca119db8e7c6fc2983289d87b27b3fac238cfe5dca529d884562", + "sha256:842fb985b2b99a82a2b145b6bbd588c5f5cfd83693402920fcb985d515794666", "sha256:8b882a78c320478b12ff024e81dc7d43c1462aa4a3341c754ee65d857a521f85", "sha256:8f6a2229e8ad946e36815f2a03386bb8353d4bde368fdf8ca5f0cb97264d3b5c", "sha256:9801c4c1d9ae6a70aeb2128e5b4b68c45d4f0af0d1535500884d644fa9b768c6", @@ -384,6 +403,7 @@ }, "scikit-learn": { "hashes": [ + "sha256:090bbf144fd5823c1f2efa3e1a9bf180295b24294ca8f478e75b40ed54f8036e", "sha256:0a127cc70990d4c15b1019680bfedc7fec6c23d14d3719fdf9b64b22d37cdeca", "sha256:0d39748e7c9669ba648acf40fb3ce96b8a07b240db6888563a7cb76e05e0d9cc", "sha256:1b8a391de95f6285a2f9adffb7db0892718950954b7149a70c783dc848f104ea", @@ -423,6 +443,7 @@ "sha256:9ad4fcddcbf5dc67619379782e6aeef41218a79e17979aaed01ed099876c0e62", "sha256:a254b98dbcc744c723a838c03b74a8a34c0558c9ac5c86d5561703362231107d", "sha256:b03c4338d6d3d299e8ca494194c0ae4f611548da59e3c038813f1a43976cb437", + "sha256:b5e9d3e4474644915809d6aa1416ff20430a3ed9ae723a5d295da5ddb24985e2", "sha256:cc1f78ebc982cd0602c9a7615d878396bec94908db67d4ecddca864d049112f2", "sha256:d6d25c41a009e3c6b7e757338948d0076ee1dd1770d1c09ec131f11946883c54", "sha256:d84cadd7d7998433334c99fa55bcba0d8b4aeff0edb123b2a1dfcface538e474", @@ -468,6 +489,7 @@ }, "watchdog": { "hashes": [ + "sha256:034c85530b647486e8c8477410fe79476511282658f2ce496f97106d9e5acfb8", "sha256:4214e1379d128b0588021880ccaf40317ee156d4603ac388b9adcf29165e0c04" ], "index": "pypi", @@ -561,6 +583,7 @@ "sha256:29a6272fec10623fcbe158fdf9abc7a5fa032048ac1d8631f14b50fbfc10d17f", "sha256:2b31f46bf7b31e6aa690d4c7a3d51bb262438c6dcb0d528adde446531d0d3bb7", "sha256:2d43af2be93ffbad25dd959899b5b809618a496926146ce98ee0b23683f8c51c", + "sha256:3188a7dfd96f734a7498f37cde6598b1e9c084f1ca68bc1aa04e88db31168ab6", "sha256:381ead10b9b9af5f64646cd27107fb27b614ee7040bb1226f9c07ba96625cbb5", "sha256:47a11bdbd8ada9b7ee628596f9d97fbd3851bd9999d398e9436bd67376dbece7", "sha256:4d6a42744139a7fa5b46a264874a781e8694bb32f1d76d8137b68138686f1729", @@ -586,7 +609,8 @@ "sha256:c851b35fc078389bc16b915a0a7c1d5923e12e2c5aeec58c52f4aa8085ac8237", "sha256:cb7df71de0af56000115eafd000b867d1261f786b5eebd88a0ca6360cccfaca7", "sha256:cedb2f9e1f990918ea061f28a0f0077a07702e3819602d3507e2ff98c8d20636", - "sha256:e8caf961e1b1a945db76f1b5fa9c91498d15f545ac0ababbe575cfab185d3bd8" + "sha256:e8caf961e1b1a945db76f1b5fa9c91498d15f545ac0ababbe575cfab185d3bd8", + "sha256:ef221855191457fffeb909d5787d1807800ab4d0111f089e6c93ee68f577634d" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", "version": "==5.3" @@ -608,6 +632,7 @@ }, "docopt": { "hashes": [ + "sha256:15fde8252aa9f2804171014d50d069ffbf42c7a50b7d74bcbb82bfd5700fcfc2", "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" ], "version": "==0.6.2" @@ -638,11 +663,11 @@ }, "faker": { "hashes": [ - "sha256:6afc461ab3f779c9c16e299fc731d775e39ea7e8e063b3053ee359ae198a15ca", - "sha256:ce1c38823eb0f927567cde5bf2e7c8ca565c7a70316139342050ce2ca74b4026" + "sha256:4d038ba51ae5e0a956d79cadd684d856e5750bfd608b61dad1807f8f08b1da49", + "sha256:f260f0375a44cd1e1a735c9b8c9b914304f607b5eef431d20e098c7c2f5b50a6" ], "markers": "python_version >= '3.5'", - "version": "==4.14.2" + "version": "==4.16.0" }, "filelock": { "hashes": [ @@ -653,6 +678,7 @@ }, "idna": { "hashes": [ + "sha256:4a57a6379512ade94fa99e2fa46d3cd0f2f553040548d0e2958c6ed90ee48226", "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" ], @@ -670,12 +696,14 @@ "iniconfig": { "hashes": [ "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:8647b85c03813b8680f4ae9c9db2fd7293f8591ea536a10d73d90f6eb4b10aac", "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" ], "version": "==1.1.1" }, "jinja2": { "hashes": [ + "sha256:3f172970d5670703bd3812e8ca6459a9a7e069fa8e51b40195f83c81db191ec4", "sha256:89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0", "sha256:f0a4641d3cf955324a89c04f3d94663aa4d638abe8f733ecd3582848e1c37035" ], @@ -689,8 +717,10 @@ "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", + "sha256:19536834abffb3fa155017053c607cb835b2ecc6a3a2554a88043d991dffb736", "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", + "sha256:3d61f15e39611aacd91b7e71d903787da86d9e80896e683c0103fced9add7834", "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", @@ -700,6 +730,7 @@ "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", + "sha256:7952deddf24b85c88dab48f6ec366ac6e39d2761b5280f2f9594911e03fcd064", "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", @@ -795,6 +826,7 @@ }, "pytest-env": { "hashes": [ + "sha256:33b4030383a021924fe3f3ba5ca4311990d8b1d02ca77389c2be020c4500f96a", "sha256:7e94956aef7f2764f3c147d216ce066bf6c42948bb9e293169b1b1c880a580c2" ], "index": "pypi", @@ -802,6 +834,7 @@ }, "pytest-forked": { "hashes": [ + "sha256:2d1bfc93ab65a28324eb0a63503bfb500c2da6916efede7a24b43a04970fe63c", "sha256:6aa9ac7e00ad1a539c41bec6d21011332de671e938c7637378ec9710204e37ca", "sha256:dc4147784048e70ef5d437951728825a131b81714b398d5d52f17c7c144d8815" ], @@ -810,6 +843,7 @@ }, "pytest-sugar": { "hashes": [ + "sha256:67a55a83c7b2717ad607704d3fe9004bb6543b54017ef82f9c6590acc38c1aec", "sha256:b1b2186b0a72aada6859bea2a5764145e3aaa2c1cfbb23c3a19b5f7b697563d3" ], "index": "pypi", @@ -927,6 +961,7 @@ }, "termcolor": { "hashes": [ + "sha256:19b1225d03bfb56571484caaa8521d8ec6e2473ae1640c9f48a48dda49417706", "sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b" ], "version": "==1.1.0" diff --git a/docker/local/Dockerfile b/docker/local/Dockerfile index 64e488f5e..0411d95ee 100644 --- a/docker/local/Dockerfile +++ b/docker/local/Dockerfile @@ -2,27 +2,25 @@ ### Back end ### ############################################################################### -FROM ubuntu:20.04 +FROM python:3.7-slim WORKDIR /usr/src/paperless/ -COPY Pipfile* ./ +COPY requirements.txt ./ #Dependencies RUN apt-get update \ - && DEBIAN_FRONTEND="noninteractive" apt-get -y --no-install-recommends install \ + && apt-get -y --no-install-recommends install \ build-essential \ curl \ ghostscript \ gnupg \ imagemagick \ + libatlas-base-dev \ libmagic-dev \ libpoppler-cpp-dev \ libpq-dev \ optipng \ - python3 \ - python3-dev \ - python3-pip \ sudo \ tesseract-ocr \ tesseract-ocr-eng \ @@ -32,10 +30,9 @@ RUN apt-get update \ tesseract-ocr-spa \ tzdata \ unpaper \ - && pip3 install --upgrade pipenv supervisor setuptools \ - && pipenv install --system --deploy \ - && pipenv --clear \ - && apt-get -y purge build-essential python3-pip python3-dev \ + && pip3 install --upgrade supervisor setuptools \ + && pip install --no-cache-dir -r requirements.txt \ + && apt-get -y purge build-essential \ && apt-get -y autoremove --purge \ && rm -rf /var/lib/apt/lists/* \ && mkdir /var/log/supervisord /var/run/supervisord diff --git a/scripts/make-release.sh b/scripts/make-release.sh index 4b509b5bf..b361834db 100755 --- a/scripts/make-release.sh +++ b/scripts/make-release.sh @@ -24,12 +24,17 @@ then rm "$PAPERLESS_DIST" -r fi +mkdir "$PAPERLESS_DIST" +mkdir "$PAPERLESS_DIST_APP" +mkdir "$PAPERLESS_DIST_APP/docker" + # setup dependencies. cd "$PAPERLESS_ROOT" pipenv clean pipenv install --dev +pipenv lock --keep-outdated -r > "$PAPERLESS_DIST_APP/requirements.txt" # test if the application works. @@ -44,10 +49,6 @@ make clean html # copy stuff into place -mkdir "$PAPERLESS_DIST" -mkdir "$PAPERLESS_DIST_APP" -mkdir "$PAPERLESS_DIST_APP/docker" - # the application itself cp "$PAPERLESS_ROOT/.env" \ @@ -92,8 +93,6 @@ cd "$PAPERLESS_DIST_APP" docker build . -t "jonaswinkler/paperless-ng:$VERSION" -docker push "jonaswinkler/paperless-ng:$VERSION" - # works. package the app! cd "$PAPERLESS_DIST" diff --git a/scripts/push-release.sh b/scripts/push-release.sh new file mode 100755 index 000000000..cfa63f5cf --- /dev/null +++ b/scripts/push-release.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + + +VERSION=$1 + +if [ -z "$VERSION" ] +then + echo "Need a version string." + exit 1 +fi + +# source root directory of paperless +PAPERLESS_ROOT=$(git rev-parse --show-toplevel) + +# output directory +PAPERLESS_DIST="$PAPERLESS_ROOT/dist" +PAPERLESS_DIST_APP="$PAPERLESS_DIST/paperless-ng" + +cd "$PAPERLESS_DIST_APP" + +docker push "jonaswinkler/paperless-ng:$VERSION"