Provide slim image without language detection instead of heavy (and broken) Anaconda version

pull/31/head
Cesura 2 years ago
parent 800803e3d8
commit 9729ac9b5b

@ -1,8 +1,9 @@
FROM tensorflow/tensorflow:2.9.1 FROM tensorflow/tensorflow:2.9.1
WORKDIR /app WORKDIR /app
COPY requirements.txt /app COPY requirements.txt /app
RUN mkdir -p /app/data && pip install -r /app/requirements.txt RUN mkdir -p /app/data && \
pip install -r /app/requirements.txt
COPY . /app/ COPY . /app/
EXPOSE 5000 EXPOSE 5000
ENV PASTEY_DATA_DIRECTORY=/app/data ENV PASTEY_DATA_DIRECTORY=/app/data
ENTRYPOINT ["python3", "app.py"] CMD ["python3", "app.py"]

@ -1,9 +0,0 @@
FROM continuumio/conda-ci-linux-64-python3.8
USER root
COPY . /app/
RUN conda install -c anaconda tensorflow=2.2.0 pip
RUN mkdir -p /app/data && pip install -r /app/requirements.txt
EXPOSE 5000
WORKDIR /app
ENV PASTEY_DATA_DIRECTORY=/app/data
ENTRYPOINT ["python3", "app.py"]

@ -0,0 +1,9 @@
FROM python:3.8.13-slim-bullseye
WORKDIR /app
COPY . /app/
RUN mkdir -p /app/data && \
./patch_no_tensorflow.sh && \
pip install -r /app/requirements.txt
EXPOSE 5000
ENV PASTEY_DATA_DIRECTORY=/app/data
CMD ["python3", "app.py"]

@ -37,10 +37,10 @@ Change **/path/to/local/dir** to a local folder you would like to use for persis
Pastey will then be accessible at *http://localhost:5000* Pastey will then be accessible at *http://localhost:5000*
### Docker (non-AVX processor) ### Docker (slim image OR non-AVX processor)
If your processor does not have support for AVX instructions, the "latest" image will fail to run. This is due to a decision by Tensorflow to enable this compile flag by default in version 1.5+. However, Anaconda's distribution of Tensorflow supports older architectures even in the 2.x line. You can instead use the image tagged ***latest-conda***: If you're interested in a slimmer image (or your processor does not have support for AVX instructions required by Tensorflow), a slim image without language detection is also maintained:
``` ```
$ docker run -d -p 5000:5000 -v /path/to/local/dir:/app/data cesura/pastey:latest-conda $ docker run -d -p 5000:5000 -v /path/to/local/dir:/app/data cesura/pastey:latest-slim
``` ```
### docker-compose ### docker-compose

@ -9,5 +9,11 @@ sed -i '/^[^#]/ s/\(^.*language = guesses.*$\)/ language = "Plaintext"/' past
sed -i '/^[^#]/ s/\(^.*from guesslang import Guess.*$\)/#\ \1/' app.py sed -i '/^[^#]/ s/\(^.*from guesslang import Guess.*$\)/#\ \1/' app.py
sed -i '/^[^#]/ s/\(^.*guess = Guess().*$\)/#\ \1/' app.py sed -i '/^[^#]/ s/\(^.*guess = Guess().*$\)/#\ \1/' app.py
# Patch common.py
sed -i '/^[^#]/ s/\(^.*from __main__ import guess.*$\)/#\ \1/' pastey/common.py
# Patch templates/new.html
sed -i '/^.*value="AUTO".*$/d' templates/new.html
# Patch requirements.txt # Patch requirements.txt
sed -i '/^[^#]/ s/\(^.*guesslang.*$\)/#\ \1/' requirements.txt sed -i '/^[^#]/ s/\(^.*guesslang.*$\)/#\ \1/' requirements.txt

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
!function(r,o){"use strict";var e,i="hljs-ln",l="hljs-ln-line",h="hljs-ln-code",s="hljs-ln-numbers",c="hljs-ln-n",m="data-line-number",a=/\r\n|\r|\n/g;function u(e){for(var n=e.toString(),t=e.anchorNode;"TD"!==t.nodeName;)t=t.parentNode;for(var r=e.focusNode;"TD"!==r.nodeName;)r=r.parentNode;var o=parseInt(t.dataset.lineNumber),a=parseInt(r.dataset.lineNumber);if(o==a)return n;var i,l=t.textContent,s=r.textContent;for(a<o&&(i=o,o=a,a=i,i=l,l=s,s=i);0!==n.indexOf(l);)l=l.slice(1);for(;-1===n.lastIndexOf(s);)s=s.slice(0,-1);for(var c=l,u=function(e){for(var n=e;"TABLE"!==n.nodeName;)n=n.parentNode;return n}(t),d=o+1;d<a;++d){var f=p('.{0}[{1}="{2}"]',[h,m,d]);c+="\n"+u.querySelector(f).textContent}return c+="\n"+s}function n(e){try{var n=o.querySelectorAll("code.hljs,code.nohighlight");for(var t in n)n.hasOwnProperty(t)&&(n[t].classList.contains("nohljsln")||d(n[t],e))}catch(e){r.console.error("LineNumbers error: ",e)}}function d(e,n){"object"==typeof e&&r.setTimeout(function(){e.innerHTML=f(e,n)},0)}function f(e,n){var t,r,o=(t=e,{singleLine:function(e){return!!e.singleLine&&e.singleLine}(r=(r=n)||{}),startFrom:function(e,n){var t=1;isFinite(n.startFrom)&&(t=n.startFrom);var r=function(e,n){return e.hasAttribute(n)?e.getAttribute(n):null}(e,"data-ln-start-from");return null!==r&&(t=function(e,n){if(!e)return n;var t=Number(e);return isFinite(t)?t:n}(r,1)),t}(t,r)});return function e(n){var t=n.childNodes;for(var r in t){var o;t.hasOwnProperty(r)&&(o=t[r],0<(o.textContent.trim().match(a)||[]).length&&(0<o.childNodes.length?e(o):v(o.parentNode)))}}(e),function(e,n){var t=g(e);""===t[t.length-1].trim()&&t.pop();if(1<t.length||n.singleLine){for(var r="",o=0,a=t.length;o<a;o++)r+=p('<tr><td class="{0} {1}" {3}="{5}"><div class="{2}" {3}="{5}"></div></td><td class="{0} {4}" {3}="{5}">{6}</td></tr>',[l,s,c,m,h,o+n.startFrom,0<t[o].length?t[o]:" "]);return p('<table class="{0}">{1}</table>',[i,r])}return e}(e.innerHTML,o)}function v(e){var n=e.className;if(/hljs-/.test(n)){for(var t=g(e.innerHTML),r=0,o="";r<t.length;r++){o+=p('<span class="{0}">{1}</span>\n',[n,0<t[r].length?t[r]:" "])}e.innerHTML=o.trim()}}function g(e){return 0===e.length?[]:e.split(a)}function p(e,t){return e.replace(/\{(\d+)\}/g,function(e,n){return void 0!==t[n]?t[n]:e})}r.hljs?(r.hljs.initLineNumbersOnLoad=function(e){"interactive"===o.readyState||"complete"===o.readyState?n(e):r.addEventListener("DOMContentLoaded",function(){n(e)})},r.hljs.lineNumbersBlock=d,r.hljs.lineNumbersValue=function(e,n){if("string"!=typeof e)return;var t=document.createElement("code");return t.innerHTML=e,f(t,n)},(e=o.createElement("style")).type="text/css",e.innerHTML=p(".{0}{border-collapse:collapse}.{0} td{padding:0}.{1}:before{content:attr({2})}",[i,c,m]),o.getElementsByTagName("head")[0].appendChild(e)):r.console.error("highlight.js not detected!"),document.addEventListener("copy",function(e){var n,t=window.getSelection();!function(e){for(var n=e;n;){if(n.className&&-1!==n.className.indexOf("hljs-ln-code"))return 1;n=n.parentNode}}(t.anchorNode)||(n=-1!==window.navigator.userAgent.indexOf("Edge")?u(t):t.toString(),e.clipboardData.setData("text/plain",n),e.preventDefault())})}(window,document);
Loading…
Cancel
Save