From 2dc067f026c666cecb96e7b582252beef6a15a73 Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Wed, 30 Dec 2015 11:23:45 +0100 Subject: [PATCH 1/6] Better Docker embedded support --- Dockerfile | 58 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 543c74d0e..b58b889ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,44 @@ -FROM python:2.7-slim +FROM alpine:3.3 +MAINTAINER Wonderfall -WORKDIR /app +ENV BASE_URL=False IMAGE_PROXY=False -RUN useradd searx +COPY . /usr/local/searx -EXPOSE 5000 -CMD ["/usr/local/bin/uwsgi", "--uid", "searx", "--gid", "searx", "--http", ":5000", "-w", "searx.webapp"] +RUN apk -U add \ + build-base \ + python \ + python-dev \ + py-pip \ + libxml2 \ + libxml2-dev \ + libxslt \ + libxslt-dev \ + libffi-dev \ + openssl \ + openssl-dev \ + ca-certificates \ + && adduser -D -h /usr/local/searx -s /bin/sh searx searx \ + && cd /usr/local/searx \ + && pip install --no-cache -r requirements.txt \ + && sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml \ + && sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml \ + && sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml \ + && sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx/settings.yml \ + && apk del \ + build-base \ + python-dev \ + py-pip\ + libffi-dev \ + openssl-dev \ + libxslt-dev \ + libxml2-dev \ + openssl-dev \ + ca-certificates \ + && chown -R searx:searx /usr/local/searx \ + && rm -f /var/cache/apk/* -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - zlib1g-dev libxml2-dev libxslt1-dev libffi-dev build-essential \ - libssl-dev openssl && \ - rm -rf /var/lib/apt/lists/* - -RUN pip install --no-cache uwsgi - -COPY requirements.txt /app/requirements.txt -RUN pip install --no-cache -r requirements.txt - -COPY . /app -RUN sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml +EXPOSE 8888 +USER searx +WORKDIR /usr/local/searx +CMD ["python", "searx/webapp.py"] From 414c4f4ca40a1cf626c3f539517ac6c5d60cce09 Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Sun, 3 Jan 2016 15:17:59 +0100 Subject: [PATCH 2/6] Better Dockerfile --- Dockerfile | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index b58b889ed..5b9638e01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,14 @@ FROM alpine:3.3 -MAINTAINER Wonderfall ENV BASE_URL=False IMAGE_PROXY=False -COPY . /usr/local/searx +EXPOSE 8888 + +WORKDIR /usr/local/searx + +CMD ["./run.sh"] + +COPY requirements.txt /usr/local/searx/requirements.txt RUN apk -U add \ build-base \ @@ -18,13 +23,7 @@ RUN apk -U add \ openssl \ openssl-dev \ ca-certificates \ - && adduser -D -h /usr/local/searx -s /bin/sh searx searx \ - && cd /usr/local/searx \ - && pip install --no-cache -r requirements.txt \ - && sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml \ - && sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml \ - && sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml \ - && sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx/settings.yml \ + && pip install --no-cache -r /usr/local/searx/requirements.txt \ && apk del \ build-base \ python-dev \ @@ -35,10 +34,21 @@ RUN apk -U add \ libxml2-dev \ openssl-dev \ ca-certificates \ - && chown -R searx:searx /usr/local/searx \ && rm -f /var/cache/apk/* -EXPOSE 8888 +COPY . /usr/local/searx + +RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \ + && chown -R searx:searx /usr/local/searx + USER searx -WORKDIR /usr/local/searx -CMD ["python", "searx/webapp.py"] + +RUN cd /usr/local/searx \ + && sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml \ + && sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml + +RUN echo '#!/bin/sh' >> run.sh \ + && echo 'sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml' >> run.sh \ + && echo 'sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx.setting.yml' >> run.sh \ + && echo 'python searx/webapp.py' >> run.sh \ + && chmod +x run.sh From b0587a022710a0b4a090c8925ff6715f4008d2a9 Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Sun, 3 Jan 2016 15:45:13 +0100 Subject: [PATCH 3/6] Better Dockerfile --- Dockerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5b9638e01..c5c56d1b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,13 @@ WORKDIR /usr/local/searx CMD ["./run.sh"] +RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \ + && echo '#!/bin/sh' >> run.sh \ + && echo 'sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml' >> run.sh \ + && echo 'sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx.setting.yml' >> run.sh \ + && echo 'python searx/webapp.py' >> run.sh \ + && chmod +x run.sh + COPY requirements.txt /usr/local/searx/requirements.txt RUN apk -U add \ @@ -38,17 +45,10 @@ RUN apk -U add \ COPY . /usr/local/searx -RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \ - && chown -R searx:searx /usr/local/searx +RUN chown -R searx:searx /usr/local/searx USER searx RUN cd /usr/local/searx \ && sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml \ && sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml - -RUN echo '#!/bin/sh' >> run.sh \ - && echo 'sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml' >> run.sh \ - && echo 'sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx.setting.yml' >> run.sh \ - && echo 'python searx/webapp.py' >> run.sh \ - && chmod +x run.sh From 5f05a3c5857a3f8f5344db093f023e21ff18f6de Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Mon, 4 Jan 2016 07:38:47 +0100 Subject: [PATCH 4/6] Better Dockerfile --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5c56d1b3..208c4d69a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \ && echo '#!/bin/sh' >> run.sh \ && echo 'sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml' >> run.sh \ && echo 'sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx.setting.yml' >> run.sh \ + && echo 'sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml' >> run.sh \ && echo 'python searx/webapp.py' >> run.sh \ && chmod +x run.sh @@ -49,6 +50,4 @@ RUN chown -R searx:searx /usr/local/searx USER searx -RUN cd /usr/local/searx \ - && sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml \ - && sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml +RUN sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml From 3dd41af67bea917827524797f4c6cbad8b73b364 Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Mon, 4 Jan 2016 12:52:59 +0100 Subject: [PATCH 5/6] Better Dockerfile --- Dockerfile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 208c4d69a..acc2b2e4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,8 @@ FROM alpine:3.3 ENV BASE_URL=False IMAGE_PROXY=False - EXPOSE 8888 - WORKDIR /usr/local/searx - CMD ["./run.sh"] RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \ @@ -16,7 +13,7 @@ RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \ && echo 'python searx/webapp.py' >> run.sh \ && chmod +x run.sh -COPY requirements.txt /usr/local/searx/requirements.txt +COPY requirements.txt . RUN apk -U add \ build-base \ @@ -31,7 +28,7 @@ RUN apk -U add \ openssl \ openssl-dev \ ca-certificates \ - && pip install --no-cache -r /usr/local/searx/requirements.txt \ + && pip install --no-cache -r requirements.txt \ && apk del \ build-base \ python-dev \ @@ -44,9 +41,9 @@ RUN apk -U add \ ca-certificates \ && rm -f /var/cache/apk/* -COPY . /usr/local/searx +COPY . . -RUN chown -R searx:searx /usr/local/searx +RUN chown -R searx:searx * USER searx From f86e212dba14f842f77e9516668d25b036e7baf4 Mon Sep 17 00:00:00 2001 From: misnyo Date: Wed, 6 Jan 2016 19:29:51 +0100 Subject: [PATCH 6/6] [fix]#485 AttributeError: 'module' object has no attribute 'old_where' --- searx/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/searx/__init__.py b/searx/__init__.py index 76038a443..7b67a394f 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -52,7 +52,8 @@ logger = logging.getLogger('searx') # Workaround for openssl versions <1.0.2 # https://github.com/certifi/python-certifi/issues/26 if OPENSSL_VERSION_INFO[0:3] < (1, 0, 2): - environ['REQUESTS_CA_BUNDLE'] = certifi.old_where() + if hasattr(certifi, 'old_where'): + environ['REQUESTS_CA_BUNDLE'] = certifi.old_where() logger.warning('You are using an old openssl version({0}), please upgrade above 1.0.2!'.format(OPENSSL_VERSION)) logger.info('Initialisation done')