diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 2b29f27645f8758ab5180164612d9f28154dee3a..0000000000000000000000000000000000000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -tests diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 445928044cb60e991558a49eaa186cb051084aea..22bf8a44f8cb3d4c4ae4e3b4a034839fcc92d4f5 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/Dockerfile b/Dockerfile index 40ac3eb320098673275e7ee864731e7f8cd8090d..d71dc69a70b15075c5d4423d4d38c09a2f1e33b2 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 diff --git a/README.rst b/README.rst index 1ad90c3fd5ba80449efd3b65871abb866212b7ad..dad0165c59e6c650184f56cd65a77605816b902d 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 029644b17b957a011e3e1929ccc6d26e5d1c8632..e0434e28be5f88c81a1dd486b5572572bc3b00c2 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 0000000000000000000000000000000000000000..139f5bf63efaa4689c17d8e1139c12f1511e070e --- /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 a3a0da13945f6dc8c6b30fd1e522ee13a2b09416..c6cd1aa3f206f4e16a67ab86040bedee6de1fef7 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 diff --git a/searx/webapp.py b/searx/webapp.py index 23188fc83f5a1d8e2a3cecf1aa6672639237b3e2..d82401fa55744bcd5379a65289a3bf418915feed 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