Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b43775c authored by Alexandre Flament's avatar Alexandre Flament
Browse files

version based on the git repository

This commit remove the need to update the brand for GIT_URL and GIT_BRANCH:
there are read from the git repository.

It is possible to call python -m searx.version freeze to freeze the current version.
Useful when the code is installed outside git (distro package, docker, etc...)
parent 24fcd747
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -60,9 +60,6 @@ ARG VERSION_GITCOMMIT=unknown
RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \
    touch -c --date=@${TIMESTAMP_SETTINGS} searx/settings.yml; \
    touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
    if [ ! -z $VERSION_GITCOMMIT ]; then\
      echo "VERSION_STRING = VERSION_STRING + \"-$VERSION_GITCOMMIT\"" >> /usr/local/searx/searx/version.py; \
    fi; \
    find /usr/local/searx/searx/static -a \( -name '*.html' -o -name '*.css' -o -name '*.js' \
    -o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
    -type f -exec gzip -9 -k {} \+ -exec brotli --best {} \+
+1 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import sys, os
from pallets_sphinx_themes import ProjectLink

from searx import get_setting
from searx.version import VERSION_STRING
from searx.version import VERSION_STRING, GIT_URL, GIT_BRANCH

# Project --------------------------------------------------------------

@@ -15,8 +15,6 @@ author = u'Adam Tauber'
release, version = VERSION_STRING, VERSION_STRING

SEARX_URL = get_setting('server.base_url') or 'https://example.org/searx'
GIT_URL = get_setting('brand.git_url')
GIT_BRANCH = get_setting('brand.git_branch')
ISSUE_URL = get_setting('brand.issue_url')
DOCS_URL = get_setting('brand.docs_url')
PUBLIC_INSTANCES = get_setting('brand.public_instances')
+2 −2
Original line number Diff line number Diff line
@@ -107,8 +107,8 @@ The ``make buildenv`` target will update the *build environment* in:
Tasks running outside of an *installed instance*, need the following settings
from the YAML configuration:

- ``GIT_URL`` from :ref:`brand.git_url <settings global brand>`
- ``GIT_BRANCH`` from :ref:`brand.git_branch <settings global brand>`
- ``GIT_URL`` from git configuration
- ``GIT_BRANCH`` from git configuration

- ``SEARX_URL`` from :ref:`server.base_url <settings global server>` (aka
  ``PUBLIC_URL``)
+11 −29
Original line number Diff line number Diff line
@@ -115,8 +115,11 @@ buildenv() {
        fi
    fi
    export SEARX_SETTINGS_PATH
    (
        set -e
        SEARX_DEBUG=1 pyenv.cmd python utils/build_env.py 2>&1 \
            | prefix_stdout "${_Blue}BUILDENV${_creset}  "
    )
    return "${PIPESTATUS[0]}"
}

@@ -200,7 +203,6 @@ docker.build() {

    local SEARX_GIT_VERSION
    local VERSION_GITCOMMIT
    local SEARX_PYTHON_VERSION
    local GITHUB_USER
    local SEARX_IMAGE_NAME
    local BUILD
@@ -227,34 +229,14 @@ docker.build() {
        fi

        # This is a git repository

        # "git describe" to get the Docker version (for example : v0.15.0-89-g0585788e)
        # awk to remove the "v" and the "g"
        SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); if ($3) { $3=substr($3, 2); }  print}')

        # add the suffix "-dirty" if the repository has uncommited change
        # /!\ HACK for searx/searx: ignore utils/brand.env
        git update-index -q --refresh
        if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'utils/brand.env')" ]; then
	    SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty"
        fi
        pyenv.cmd python -m searx.version freeze
        eval "$(pyenv.cmd python -m searx.version)"

        # Get the last git commit id, will be added to the Searx version (see Dockerfile)
        VERSION_GITCOMMIT=$(echo "$SEARX_GIT_VERSION" | cut -d- -f2-4)
        # Get the last git commit id
        VERSION_GITCOMMIT=$(echo "$VERSION_STRING" | cut -d- -f3)
        build_msg DOCKER "Last commit : $VERSION_GITCOMMIT"

        # Check consistency between the git tag and the searx/version.py file
        # /! HACK : parse Python file with bash /!
        # otherwise it is not possible build the docker image without all Python
        # dependencies ( version.py loads __init__.py )
        # SEARX_PYTHON_VERSION=$(python3 -c "import six; import searx.version; six.print_(searx.version.VERSION_STRING)")
        SEARX_PYTHON_VERSION=$(cat searx/version.py | grep "\(VERSION_MAJOR\|VERSION_MINOR\|VERSION_BUILD\) =" | cut -d\= -f2 | sed -e 's/^[[:space:]]*//' | paste -sd "." -)
        if [ "$(echo "$SEARX_GIT_VERSION" | cut -d- -f1)" != "$SEARX_PYTHON_VERSION" ]; then
	    err_msg "git tag:          $SEARX_GIT_VERSION"
	    err_msg "searx/version.py: $SEARX_PYTHON_VERSION"
	    die 1 "Inconsistency between the last git tag and the searx/version.py file"
        fi

        # define the docker image name
        GITHUB_USER=$(echo "${GIT_URL}" | sed 's/.*github\.com\/\([^\/]*\).*/\1/')
        SEARX_IMAGE_NAME="${SEARX_IMAGE_NAME:-${GITHUB_USER:-searxng}/searxng}"
@@ -274,14 +256,14 @@ docker.build() {
        docker $BUILD \
         --build-arg BASE_IMAGE="${DEPENDENCIES_IMAGE_NAME}" \
         --build-arg GIT_URL="${GIT_URL}" \
         --build-arg SEARX_GIT_VERSION="${SEARX_GIT_VERSION}" \
         --build-arg SEARX_GIT_VERSION="${VERSION_STRING}" \
         --build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \
         --build-arg LABEL_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
         --build-arg LABEL_VCS_REF="$(git rev-parse HEAD)" \
         --build-arg LABEL_VCS_URL="${GIT_URL}" \
         --build-arg TIMESTAMP_SETTINGS="$(git log -1 --format="%cd" --date=unix -- searx/settings.yml)" \
         --build-arg TIMESTAMP_UWSGI="$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini)" \
         -t "${SEARX_IMAGE_NAME}:latest" -t "${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}" .
         -t "${SEARX_IMAGE_NAME}:latest" -t "${SEARX_IMAGE_NAME}:${VERSION_STRING}" .

        if [ "$1" = "push" ]; then
	        docker push "${SEARX_IMAGE_NAME}:latest"
+0 −5
Original line number Diff line number Diff line
@@ -10,11 +10,6 @@ brand:
  wiki_url: https://github.com/searxng/searxng/wiki
  issue_url: https://github.com/searxng/searxng/issues

  # If you change a value below don't forget to rebuild instance's enviroment
  # (make buildenv)
  git_url: https://github.com/searxng/searxng
  git_branch: master

search:
  # Filter results. 0: None, 1: Moderate, 2: Strict
  safe_search: 0
Loading