From 51d590ea3f5404fd3b59bd6c8635e2fd66da028e Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Mon, 7 Jan 2019 23:44:05 +0100 Subject: [PATCH 1/3] Dockerfile, rework the command and termination To avoid to wait 10s when we stop the spot container, this patch performs some changes to only run the python binary in the container. Tini is included in docker itself since 1.13 or greater, so it is removed and the environments variables are handled in the application, that change avoids to use a bash script to patch the configuration. --- Dockerfile | 17 +++++------------ searx/__init__.py | 4 ++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1680c7bb2..b1b9b18cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,23 +2,15 @@ FROM alpine:3.8 LABEL maintainer="searx " LABEL description="A privacy-respecting, hackable metasearch engine." -ENV BASE_URL=False IMAGE_PROXY=False EXPOSE 8888 WORKDIR /usr/local/searx -CMD ["/sbin/tini","--","/usr/local/searx/run.sh"] +CMD ["python", "searx/webapp.py"] -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/settings.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 +RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx COPY requirements.txt ./requirements.txt -RUN echo "@commuedge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && apk -U add \ +RUN apk -U add \ build-base \ python \ python-dev \ @@ -31,7 +23,6 @@ RUN echo "@commuedge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/ap openssl \ openssl-dev \ ca-certificates \ - tini@commuedge \ && pip install --upgrade pip \ && pip install --no-cache -r requirements.txt \ && apk del \ @@ -52,3 +43,5 @@ RUN chown -R searx:searx * USER searx RUN sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml + +STOPSIGNAL SIGINT diff --git a/searx/__init__.py b/searx/__init__.py index b1010f25f..9426ebf13 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -91,3 +91,7 @@ logger.info('Initialisation done') if 'SEARX_SECRET' in environ: settings['server']['secret_key'] = environ['SEARX_SECRET'] +if 'BASE_URL' in environ: + settings['server']['base_url'] = environ['BASE_URL'] +if 'IMAGE_PROXY' in environ: + settings['server']['image_proxy'] = environ['IMAGE_PROXY'] -- GitLab From 0adf7bb1f5418adb0229c1b5ba0d75fe2a90726d Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Mon, 7 Jan 2019 23:44:05 +0100 Subject: [PATCH 2/3] Fix redis Python libray to 2.10.6 Spot project does not work with the new Python client redis 3.X --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 10d30c09e..546b8b761 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -redis +redis==2.10.6 certifi==2017.11.5 flask==1.0.2 flask-babel==0.11.2 -- GitLab From 31f7f219c25495438289c0a7b87a9251b18f9733 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Mon, 7 Jan 2019 23:44:05 +0100 Subject: [PATCH 3/3] Docker-compose, introduce docker-compose to run spot In order to run the project in a dedicated environment this patch introduces the docker-compose file. To join redis service a setup via an environment variable `SEARX_REDIS_HOST` is added. --- README.rst | 27 ++++++++++++--------------- docker-compose.yml | 10 ++++++++++ searx/__init__.py | 2 ++ 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 docker-compose.yml diff --git a/README.rst b/README.rst index 6e3339cc7..371d9fbed 100644 --- a/README.rst +++ b/README.rst @@ -9,25 +9,22 @@ Spot was forked from searx: read `documentation `__ - (set your ``secret_key``!) -- run ``python searx/webapp.py`` to start the application +You can run spot with docker-compose to run the **redis** database and +the **spot** service. First of all you have to install **docker** and +**docker-compose** on your host, then follow instructions below to run spot +with one command. + +- Run the docker-compose **up** command to start the project ``docker-compose up --build`` +- Getting the ip of the spot service and go to http://:8888 + +.. note:: Here the command to get the IP of the spot service + ``docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my-spot_spot_1`` -For all the details, follow this `step by step +You can also install **redis** and **spot** on your host, for all the details, follow this `step by step installation `__. Bugs diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..a1eec9941 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.6' + +services: + redis: + image: redis:5-alpine + + spot: + build: . + environment: + SEARX_REDIS_HOST: redis diff --git a/searx/__init__.py b/searx/__init__.py index 9426ebf13..0dd557b7f 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -95,3 +95,5 @@ if 'BASE_URL' in environ: settings['server']['base_url'] = environ['BASE_URL'] if 'IMAGE_PROXY' in environ: settings['server']['image_proxy'] = environ['IMAGE_PROXY'] +if 'SEARX_REDIS_HOST' in environ: + settings['redis']['host'] = environ['SEARX_REDIS_HOST'] -- GitLab