diff --git a/Dockerfile b/Dockerfile index b3e7a2efd5eee8e2005df37df22df0c54b9f9c67..70fb0323bb14b67f157d02f6017bc08a6cefaf23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,34 @@ +FROM python:3.7-alpine as builder + +RUN apk add \ + git \ + build-base \ + libxml2-dev \ + libxslt-dev \ + libffi-dev \ + openssl-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 + + FROM python:3.7-alpine LABEL maintainer="searx " LABEL description="A privacy-respecting, hackable metasearch engine." -EXPOSE 8888 -WORKDIR /usr/local/searx -CMD ["python", "searx/webapp.py"] - -COPY requirements.txt ./requirements.txt - -RUN apk -U add \ - build-base \ - libxml2 \ - libxml2-dev \ - libxslt \ - libxslt-dev \ - libffi-dev \ - openssl \ - openssl-dev \ - ca-certificates \ - && pip install -r requirements.txt \ - && pip install coverage \ - && apk del \ - build-base \ - libffi-dev \ - openssl-dev \ - libxslt-dev \ - libxml2-dev \ - openssl-dev \ - ca-certificates \ - && rm -f /var/cache/apk/* - -COPY searx /usr/local/searx/searx - -RUN sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml +RUN apk add \ + ca-certificates \ + libxslt \ + openssl \ +&& pip install coverage +COPY --from=builder /install/ /usr/local/ + +EXPOSE 8888 STOPSIGNAL SIGINT +CMD ["searx-run"] diff --git a/docker-compose-coverage.yml b/docker-compose-coverage.yml index bd10ea3e48a6e89579fc2823c9d97417dd2561af..029644b17b957a011e3e1929ccc6d26e5d1c8632 100644 --- a/docker-compose-coverage.yml +++ b/docker-compose-coverage.yml @@ -7,7 +7,7 @@ services: - run - --source=searx command: - - searx/webapp.py + - /usr/local/bin/searx-run volumes: - coverage:/coverage environment: diff --git a/manage.sh b/manage.sh index 79fdd244e7e1ebed1e38c750e9b2d3caac6214d5..47da7b36e7b850dba5c655678340c74d61f5b353 100755 --- a/manage.sh +++ b/manage.sh @@ -59,7 +59,7 @@ functional_tests() { } coverage() { - sed -i 's!/usr/local/searx!'$BASE_DIR'!g' "$COV_DIR"/func + sed -i 's!/usr/local/lib/python3.7/site-packages/searx[^/]*/searx!'$SEARX_DIR'!g' "$COV_DIR"/func coverage3 combine coverage/func coverage/unit coverage3 report } diff --git a/searx/settings.yml b/searx/settings.yml index 07b2fefe415aa83f8220908ffa2c8e19efe24cb3..e1ceb844dcd2543835f96b783b16e5753326a747 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -11,7 +11,7 @@ search: server: port : 8888 - bind_address : "127.0.0.1" # address to listen on + bind_address : "0.0.0.0" # address to listen on secret_key : "ultrasecretkey" # change this! base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/" image_proxy : False # Proxying image results through searx diff --git a/searx/version.py b/searx/version.py index 4e149722e547a7a4898af9bb1ecc7f9adeb7b930..473eb722d04489ddf53a0f4685ec13fc3c231959 100644 --- a/searx/version.py +++ b/searx/version.py @@ -16,11 +16,9 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. (C) 2013- by Adam Tauber, ''' -# version of searx -VERSION_MAJOR = 0 -VERSION_MINOR = 15 -VERSION_BUILD = 0 +from pkg_resources import get_distribution, DistributionNotFound -VERSION_STRING = "{0}.{1}.{2}".format(VERSION_MAJOR, - VERSION_MINOR, - VERSION_BUILD) +try: + VERSION_STRING = get_distribution("searx").version +except DistributionNotFound: + VERSION_STRING = "0.0.0" diff --git a/setup.py b/setup.py index 7333551fe664f7e266c55e6942d36e1c60e8dba1..b7f144baa970968e86486e5a38a5ee24015375d0 100644 --- a/setup.py +++ b/setup.py @@ -4,27 +4,15 @@ from setuptools import setup from setuptools import find_packages -import os -import sys -# required to load VERSION_STRING constant -sys.path.insert(0, './searx') -from version import VERSION_STRING - - -def read(*rnames): - return open(os.path.join(os.path.dirname(__file__), *rnames)).read() - - -long_description = read('README.rst') -requirements = map(str.strip, open('requirements.txt').readlines()) -dev_requirements = map(str.strip, open('requirements-dev.txt').readlines()) +requirements = open('requirements.txt').read().splitlines() +dev_requirements = open('requirements-dev.txt').read().splitlines() setup( name='searx', - version=VERSION_STRING, + use_scm_version=True, description="A privacy-respecting, hackable metasearch engine", - long_description=long_description, + long_description=open('README.rst').read(), classifiers=[ "Development Status :: 4 - Beta", "Programming Language :: Python", @@ -41,6 +29,7 @@ setup( packages=find_packages(exclude=["tests*"]), zip_safe=False, install_requires=requirements, + setup_requires=["setuptools_scm"], extras_require={ 'test': dev_requirements }, @@ -52,9 +41,6 @@ setup( package_data={ 'searx': [ 'settings.yml', - '../README.rst', - '../requirements.txt', - '../requirements-dev.txt', 'data/*', 'plugins/*/*', 'static/*.*', @@ -64,11 +50,7 @@ setup( 'static/*/*/*/*/*.*', 'templates/*/*.*', 'templates/*/*/*.*', - 'tests/*', - 'tests/*/*', - 'tests/*/*/*', 'translations/*/*/*' ], }, - ) diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index cfade83ac302ceb8138139f4de95bd0117964731..22fe91e285b78c85ba3672d2a89731c297f763a5 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -13,7 +13,9 @@ class SpotContext(Context): return f"http://{addr}:{port}" def wait_for_running_state(self): - Wait(ignored_exns=(requests.ConnectionError,))(lambda: requests.get(self.url)) + Wait(ignored_exns=(requests.ConnectionError,), timeout=60)( + lambda: requests.get(self.url) + ) @pytest.fixture(scope="session")