From 914e6e315963ad8e25ed80ab640aa9971acab589 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Wed, 20 Apr 2022 20:31:26 +0200 Subject: [PATCH 1/3] Remove scripts --- README.md | 7 ++- searxng-docker.service.template | 10 ++-- start.sh | 11 ---- stop.sh | 9 ---- update.sh | 93 --------------------------------- util.sh | 26 --------- 6 files changed, 10 insertions(+), 146 deletions(-) delete mode 100755 start.sh delete mode 100755 stop.sh delete mode 100755 update.sh delete mode 100644 util.sh diff --git a/README.md b/README.md index ab6cbcc..660e089 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,12 @@ Create a new SearXNG instance in five minutes using Docker - Edit the [.env](https://github.com/searxng/searxng-docker/blob/master/.env) file to set the hostname and an email - Generate the secret key ```sed -i "s|ultrasecretkey|$(openssl rand -hex 32)|g" searxng/settings.yml``` - Edit the [searxng/settings.yml](https://github.com/searxng/searxng-docker/blob/master/searxng/settings.yml) file according to your need -- Check everything is working: ```./start.sh``` +- Check everything is working: ```docker-compose up``` + +### Start SearXNG with systemd + +You can skip this step if you don't use systemd. + - ```cp searxng-docker.service.template searxng-docker.service``` - edit the content of ```WorkingDirectory``` in the ```searxng-docker.service``` file (only if the installation path is different from /usr/local/searxng-docker) - Install the systemd unit: diff --git a/searxng-docker.service.template b/searxng-docker.service.template index 6744b01..93c24ff 100644 --- a/searxng-docker.service.template +++ b/searxng-docker.service.template @@ -4,13 +4,11 @@ Requires=docker.service After=docker.service [Service] -Restart=always +Restart=on-failure -Environment=SEARXNG_DIR=/usr/local/searxng-docker -Environment=SEARXNG_DOCKERCOMPOSEFILE=docker-compose.yaml - -ExecStart=/bin/sh -c "${SEARXNG_DIR}/start.sh" -ExecStop=/bin/sh -c "${SEARXNG_DIR}/stop.sh" +WorkingDirectory=/usr/local/searxng-docker +ExecStart=/usr/local/bin/docker-compose up --remove-orphans +ExecStop=/usr/local/bin/docker-compose down [Install] WantedBy=multi-user.target diff --git a/start.sh b/start.sh deleted file mode 100755 index 9a5a760..0000000 --- a/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -READLINK="$(which readlink greadlink | tail -n1)" -BASE_DIR="$(dirname -- "`$READLINK -f -- "$0"`")" -cd -- "$BASE_DIR" - -. ./util.sh - -$DOCKERCOMPOSE -f $DOCKERCOMPOSEFILE down -$DOCKERCOMPOSE -f $DOCKERCOMPOSEFILE rm -fv -$DOCKERCOMPOSE -f $DOCKERCOMPOSEFILE up diff --git a/stop.sh b/stop.sh deleted file mode 100755 index 48f609b..0000000 --- a/stop.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -READLINK="$(which readlink greadlink | tail -n1)" -BASE_DIR="$(dirname -- "`$READLINK -f -- "$0"`")" -cd -- "$BASE_DIR" - -. ./util.sh - -$DOCKERCOMPOSE -f $DOCKERCOMPOSEFILE down diff --git a/update.sh b/update.sh deleted file mode 100755 index b85eba6..0000000 --- a/update.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -# -# Disclaimer: this is more a documentation than code to execute -# - -# change if require -SERVICE_NAME="searxng-docker.service" - -# change if require : -# fastforward : only fast-forward -# rebase : rebase with autostash, at your own risk -UPDATE_TYPE="fastforward" - -READLINK="$(which readlink greadlink | tail -n1)" -BASE_DIR="$(dirname -- "`$READLINK -f -- "$0"`")" -cd -- "$BASE_DIR" - -# check if git presence -if [ ! -x "$(which git)" ]; then - echo "git not found" 1>&2 - exit 1 -fi - -# check if the current user owns the local git repository -git_owner=$(stat -c '%U' .git) -if [ "$git_owner" != "$(whoami)" ]; then - echo "The .git repository is own by $git_owner" 1>&2 - exit 1 -fi - -# warning if the current branch is not master -current_branch=$(git rev-parse --abbrev-ref HEAD) -if [ "$current_branch" != "master" ]; then - echo "Warning: master won't be updated, only $current_branch" -fi - -# git fetch first -git fetch origin master - -# is everything already up-to-date ? -current_commit=$(git rev-parse $current_branch) -origin_master_commit=$(git rev-parse origin/master) -if [ "$current_commit" = "$origin_master_commit" ]; then - echo "Already up-to-date, commit $current_commit" - exit 0 -fi - -# docker stuff -SEARXNG_DOCKERCOMPOSE=$(grep "Environment=SEARXNG_DOCKERCOMPOSEFILE=" "$SERVICE_NAME" | awk -F\= '{ print $3 }') -. ./util.sh - -if [ ! -x "$(which systemctl)" ]; then - echo "systemctl not found" 1>&2 - exit 1 -fi - -# stop the systemd service now, because after the update -# the code might be out of sync with the current running services -systemctl stop "${SERVICE_NAME}" - -# update -case "$UPDATE_TYPE" in - "fastforward") - git pull --ff-only origin master - ;; - "rebase") - git pull --rebase --autostash origin master - ;; -esac - -# Check conflicts -if [ $(git ls-files -u | wc -l) -gt 0 ]; then - echo "There are git conflicts" -else - # update docker images - docker-compose -f $DOCKERCOMPOSEFILE pull - - # remove dangling images - docker rmi $(docker images -f "dangling=true" -q) - - # display SearxNG version - SEARXNG_IMAGE=$(cat $DOCKERCOMPOSEFILE | grep "searxng/searxng" | awk '{ print $2 }') - SEARXNG_VERSION=$(docker inspect -f '{{index .Config.Labels "org.label-schema.version"}}' $SEARXNG_IMAGE) - echo "SearXNG version: $SEARXNG_VERSION" - docker images --digests "searxng/*:latest" - - # update SearxNG configuration - source ./.env - docker-compose -f $DOCKERCOMPOSEFILE run searxng ${SEARXNG_COMMAND} -d - - # let the user see - echo "Use\nsystemctl start \"${SERVICE_NAME}\"\nto restart SearXNG" -fi diff --git a/util.sh b/util.sh deleted file mode 100644 index 9cfd4d0..0000000 --- a/util.sh +++ /dev/null @@ -1,26 +0,0 @@ -set -e - -DOCKERCOMPOSE=$(which docker-compose || echo "/usr/local/bin/docker-compose") -DOCKERCOMPOSEFILE="${DOCKERCOMPOSEFILE:-docker-compose.yaml}" - -echo "use ${DOCKERCOMPOSEFILE}" - -if [ ! -x "$(which docker)" ]; then - echo "docker not found" 1>&2 - exit 1 -fi - -if ! docker version > /dev/null 2>&1; then - echo "can't execute docker (current user: $(whoami))" 1>&2 - exit 1 -fi - -if [ ! -x "${DOCKERCOMPOSE}" ]; then - echo "docker-compose not found" 1>&2 - exit 1 -fi - -if [ ! -f "${DOCKERCOMPOSEFILE}" ]; then - echo "${DOCKERCOMPOSEFILE} not found" 1>&2 - exit 1 -fi From d4ae67a468e93f8c36ef39e06a58076793606804 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Fri, 22 Apr 2022 09:45:47 +0200 Subject: [PATCH 2/3] Remove scripts 2/n --- README.md | 5 ----- docker-compose.yaml | 1 - searxng-docker.service.template | 6 ++++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 660e089..3bafe23 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ Create a new SearXNG instance in five minutes using Docker ## How to use it - [Install docker](https://docs.docker.com/install/) - [Install docker-compose](https://docs.docker.com/compose/install/) (be sure that docker-compose version is at least 1.9.0) -- only on MacOSX: ```brew install coreutils``` to install ```greadlink``` - Get searxng-docker ```sh cd /usr/local @@ -61,7 +60,3 @@ Supported architecture: - amd64 - arm64 - arm/v7 - -## How to update ? - -Check the content of [```update.sh```](https://github.com/searxng/searxng-docker/blob/master/update.sh) diff --git a/docker-compose.yaml b/docker-compose.yaml index 4a153f9..f592709 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -37,7 +37,6 @@ services: searxng: container_name: searxng image: searxng/searxng:latest - restart: always networks: - searxng ports: diff --git a/searxng-docker.service.template b/searxng-docker.service.template index 93c24ff..acd6af7 100644 --- a/searxng-docker.service.template +++ b/searxng-docker.service.template @@ -6,9 +6,11 @@ After=docker.service [Service] Restart=on-failure +Environment=SEARXNG_DOCKERCOMPOSEFILE=docker-compose.yaml + WorkingDirectory=/usr/local/searxng-docker -ExecStart=/usr/local/bin/docker-compose up --remove-orphans -ExecStop=/usr/local/bin/docker-compose down +ExecStart=/usr/local/bin/docker-compose -f ${SEARXNG_DOCKERCOMPOSEFILE} up --remove-orphans +ExecStop=/usr/local/bin/docker-compose -f ${SEARXNG_DOCKERCOMPOSEFILE} down [Install] WantedBy=multi-user.target From 2504dcbd57bcb527a5ed1bc76a433fd82856aa05 Mon Sep 17 00:00:00 2001 From: mrpaulblack Date: Tue, 26 Apr 2022 14:27:30 +0200 Subject: [PATCH 3/3] Remove scripts 3/n --- README.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3bafe23..43316d1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Create a new SearXNG instance in five minutes using Docker - Generate the secret key ```sed -i "s|ultrasecretkey|$(openssl rand -hex 32)|g" searxng/settings.yml``` - Edit the [searxng/settings.yml](https://github.com/searxng/searxng-docker/blob/master/searxng/settings.yml) file according to your need - Check everything is working: ```docker-compose up``` +- Run SearXNG in the background: ```docker-compose up -d``` ### Start SearXNG with systemd @@ -44,19 +45,23 @@ The default [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/W If some users wants to disable the image proxy, you have to modify [./Caddyfile](https://github.com/searxng/searxng-docker/blob/master/Caddyfile). Replace the ```img-src 'self' data: https://*.tile.openstreetmap.org;``` by ```img-src * data:;```. -## Custom docker-compose.yaml - -Do not modify docker-compose.yaml otherwise you won't be able to update easily from the git repository. - -It is possible to use the [extend feature](https://docs.docker.com/compose/extends/) of docker-compose: -- stop the service: ```systemctl stop searxng-docker.service``` -- create a new docker-compose-extend.yaml, check with ```start.sh``` -- update searxng-docker.service (see SEARXNG_DOCKERCOMPOSEFILE) -- restart the service: ```systemctl restart searxng-docker.service``` - ## Multi Architecture Docker images Supported architecture: - amd64 - arm64 - arm/v7 + +## How to update ? + +To update the SearXNG stack: + +```sh +docker-compose pull +docker-compose down +docker-compose up +``` + +To update this `docker-compose.yml` file: + +Check out the newest version on github: [searxng/searxng-docker](https://github.com/searxng/searxng-docker). \ No newline at end of file