From 052b5592a2b480daa8363541c32e97e96bac5732 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Thu, 16 May 2019 21:54:48 +0200 Subject: [PATCH 1/3] Fix first page render This pathc fixes the render of the first page. This one have to display general results plus a sample of 5 images and 2 videos. Previously, torrent and videos results were included. This change is related to the comment https://gitlab.e.foundation/e/cloud/my-spot/issues/30#note_10233 --- searx/webapp.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index 23188fc83..d82401fa5 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -510,16 +510,10 @@ def index(): results_copy = copy.deepcopy(search_data.results) if is_general_first_page: - for res in results_copy: - if res.get('category') == 'images': - if len(images) < 5: - images.append(res) - results_copy.remove(res) - elif res.get('category') == 'videos': - if len(videos) < 2: - videos.append(res) - results_copy.remove(res) - elif res.get('category') is None: + images = [r for r in results_copy if r.get('category') == 'images'][:5] + videos = [r for r in results_copy if r.get('category') == 'videos'][:2] + for res in search_data.results: + if res.get('category') != 'general': results_copy.remove(res) # output -- GitLab From b95c6ec1678bf2ab41ed7a079a209fa24fa908cc Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Wed, 15 May 2019 16:53:20 +0200 Subject: [PATCH 2/3] Fix python package build in docker env --- .dockerignore | 1 - Dockerfile | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 2b29f2764..000000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -tests diff --git a/Dockerfile b/Dockerfile index 40ac3eb32..d71dc69a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,13 +6,8 @@ RUN apk add \ libxml2-dev \ libxslt-dev -# Only to use the docker cache and optimize the build time -WORKDIR /src -COPY requirements.txt /src/requirements.txt -RUN pip3 install --prefix /install -r requirements.txt - COPY . /src/ -RUN PYTHONPATH=/install/lib/python3.7/site-packages/ python3 setup.py install --prefix /install +RUN pip3 install --prefix /install /src FROM python:3.7-alpine -- GitLab From 88b1ef77afecaaa6d6f0c6173de3b622652a39a8 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Wed, 15 May 2019 23:19:12 +0200 Subject: [PATCH 3/3] Update prod deployement to use tagged docker image Close: #31 --- .gitlab-ci.yml | 6 +++++- README.rst | 1 + docker-compose-coverage.yml | 1 + docker-compose-dev.yml | 5 +++++ docker-compose.yml | 2 +- 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 docker-compose-dev.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 445928044..22bf8a44f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,8 +94,9 @@ coverage: - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts script: + - ssh -2 $PUBLISH_USER@$PUBLISH_URL "docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}" - ssh -2 $PUBLISH_USER@$PUBLISH_URL "mkdir -p ${DEPLOY_FOLDER} && cd ${DEPLOY_FOLDER} && if [ ! -d ${CI_PROJECT_NAME} ] ; then git clone ${CI_PROJECT_URL}.git ; fi && cd ${CI_PROJECT_NAME} && git fetch && git checkout $CI_COMMIT_SHA" - - ssh -2 $PUBLISH_USER@$PUBLISH_URL "SPOT_HOSTNAME=$SPOT_HOSTNAME && export SPOT_HOSTNAME && cd ${DEPLOY_FOLDER}/${CI_PROJECT_NAME} && docker-compose pull && docker-compose up -d --build --force-recreate" + - ssh -2 $PUBLISH_USER@$PUBLISH_URL "SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG && COMPOSE_FILE=$COMPOSE_FILE && SPOT_HOSTNAME=$SPOT_HOSTNAME && export SPOT_HOSTNAME COMPOSE_FILE SPOT_DOCKER_TAG && cd ${DEPLOY_FOLDER}/${CI_PROJECT_NAME} && docker-compose pull && docker-compose up -d --build --force-recreate" test: extends: .deploy:template @@ -105,6 +106,7 @@ test: GIT_STRATEGY: none SPOT_HOSTNAME: spot.test.ecloud.global SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY_TEST} + COMPOSE_FILE: docker-compose.yml:docker-compose-dev.yml prod: extends: .deploy:template @@ -115,4 +117,6 @@ prod: PUBLISH_URL: spot.ecloud.global GIT_STRATEGY: none SPOT_HOSTNAME: spot.ecloud.global + SPOT_DOCKER_TAG: ${CI_COMMIT_TAG} SSH_PRIVATE_KEY: ${SSH_PRIVATE_KEY_PROD} + COMPOSE_FILE: docker-compose.yml diff --git a/README.rst b/README.rst index 1ad90c3fd..dad0165c5 100644 --- a/README.rst +++ b/README.rst @@ -34,6 +34,7 @@ First run the redis database: Then on spot workdir run the following commands to start spot: +- ``export COMPOSE_FILE=docker-compose.yml:docker-compose-dev.yml`` - ``docker-compose build spot`` - ``docker-compose run --rm -v $(pwd):/ws -w /ws -e PYTHONPATH=/ws spot sh`` - ``python3 -X dev searx/webapp.py`` diff --git a/docker-compose-coverage.yml b/docker-compose-coverage.yml index 029644b17..e0434e28b 100644 --- a/docker-compose-coverage.yml +++ b/docker-compose-coverage.yml @@ -2,6 +2,7 @@ version: '3.6' services: spot: + build: . entrypoint: - coverage - run diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 000000000..139f5bf63 --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,5 @@ +version: '3.6' + +services: + spot: + build: . diff --git a/docker-compose.yml b/docker-compose.yml index a3a0da139..c6cd1aa3f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: image: redis:5-alpine spot: - build: . + image: registry.gitlab.e.foundation:5000/e/cloud/my-spot:${SPOT_DOCKER_TAG:-latest} restart: unless-stopped environment: SEARX_REDIS_HOST: redis -- GitLab