forked from zaclys/searxng
SearXNG: docker
This commit is contained in:
parent
64df011e2f
commit
9e03823b98
31
Dockerfile
31
Dockerfile
|
@ -1,24 +1,25 @@
|
||||||
FROM alpine:3.14
|
FROM alpine:3.14
|
||||||
ENTRYPOINT ["/sbin/tini","--","/usr/local/searx/dockerfiles/docker-entrypoint.sh"]
|
ENTRYPOINT ["/sbin/tini","--","/usr/local/searxng/dockerfiles/docker-entrypoint.sh"]
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
VOLUME /etc/searx
|
VOLUME /etc/searx
|
||||||
|
VOLUME /etc/searxng
|
||||||
VOLUME /var/log/uwsgi
|
VOLUME /var/log/uwsgi
|
||||||
|
|
||||||
ARG SEARX_GID=977
|
ARG SEARXNG_GID=977
|
||||||
ARG SEARX_UID=977
|
ARG SEARXNG_UID=977
|
||||||
|
|
||||||
RUN addgroup -g ${SEARX_GID} searx && \
|
RUN addgroup -g ${SEARXNG_GID} searxng && \
|
||||||
adduser -u ${SEARX_UID} -D -h /usr/local/searx -s /bin/sh -G searx searx
|
adduser -u ${SEARXNG_UID} -D -h /usr/local/searxng -s /bin/sh -G searxng searxng
|
||||||
|
|
||||||
ENV INSTANCE_NAME=searxng \
|
ENV INSTANCE_NAME=searxng \
|
||||||
AUTOCOMPLETE= \
|
AUTOCOMPLETE= \
|
||||||
BASE_URL= \
|
BASE_URL= \
|
||||||
MORTY_KEY= \
|
MORTY_KEY= \
|
||||||
MORTY_URL= \
|
MORTY_URL= \
|
||||||
SEARXNG_SETTINGS_PATH=/etc/searx/settings.yml \
|
SEARXNG_SETTINGS_PATH=/etc/searxng/settings.yml \
|
||||||
UWSGI_SETTINGS_PATH=/etc/searx/uwsgi.ini
|
UWSGI_SETTINGS_PATH=/etc/searxng/uwsgi.ini
|
||||||
|
|
||||||
WORKDIR /usr/local/searx
|
WORKDIR /usr/local/searxng
|
||||||
|
|
||||||
|
|
||||||
COPY requirements.txt ./requirements.txt
|
COPY requirements.txt ./requirements.txt
|
||||||
|
@ -51,38 +52,38 @@ RUN apk upgrade --no-cache \
|
||||||
&& apk del build-dependencies \
|
&& apk del build-dependencies \
|
||||||
&& rm -rf /root/.cache
|
&& rm -rf /root/.cache
|
||||||
|
|
||||||
COPY --chown=searx:searx . .
|
COPY --chown=searxng:searxng . .
|
||||||
|
|
||||||
ARG TIMESTAMP_SETTINGS=0
|
ARG TIMESTAMP_SETTINGS=0
|
||||||
ARG TIMESTAMP_UWSGI=0
|
ARG TIMESTAMP_UWSGI=0
|
||||||
ARG VERSION_GITCOMMIT=unknown
|
ARG VERSION_GITCOMMIT=unknown
|
||||||
|
|
||||||
RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \
|
RUN su searxng -c "/usr/bin/python3 -m compileall -q searx"; \
|
||||||
touch -c --date=@${TIMESTAMP_SETTINGS} searx/settings.yml; \
|
touch -c --date=@${TIMESTAMP_SETTINGS} searx/settings.yml; \
|
||||||
touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
|
touch -c --date=@${TIMESTAMP_UWSGI} dockerfiles/uwsgi.ini; \
|
||||||
find /usr/local/searx/searx/static -a \( -name '*.html' -o -name '*.css' -o -name '*.js' \
|
find /usr/local/searxng/searx/static -a \( -name '*.html' -o -name '*.css' -o -name '*.js' \
|
||||||
-o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
|
-o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
|
||||||
-type f -exec gzip -9 -k {} \+ -exec brotli --best {} \+
|
-type f -exec gzip -9 -k {} \+ -exec brotli --best {} \+
|
||||||
|
|
||||||
# Keep these arguments at the end to prevent redundant layer rebuilds
|
# Keep these arguments at the end to prevent redundant layer rebuilds
|
||||||
ARG LABEL_DATE=
|
ARG LABEL_DATE=
|
||||||
ARG GIT_URL=unknown
|
ARG GIT_URL=unknown
|
||||||
ARG SEARX_GIT_VERSION=unknown
|
ARG SEARXNG_GIT_VERSION=unknown
|
||||||
ARG LABEL_VCS_REF=
|
ARG LABEL_VCS_REF=
|
||||||
ARG LABEL_VCS_URL=
|
ARG LABEL_VCS_URL=
|
||||||
LABEL maintainer="searxng <${GIT_URL}>" \
|
LABEL maintainer="searxng <${GIT_URL}>" \
|
||||||
description="A privacy-respecting, hackable metasearch engine." \
|
description="A privacy-respecting, hackable metasearch engine." \
|
||||||
version="${SEARX_GIT_VERSION}" \
|
version="${SEARXNG_GIT_VERSION}" \
|
||||||
org.label-schema.schema-version="1.0" \
|
org.label-schema.schema-version="1.0" \
|
||||||
org.label-schema.name="searxng" \
|
org.label-schema.name="searxng" \
|
||||||
org.label-schema.version="${SEARX_GIT_VERSION}" \
|
org.label-schema.version="${SEARXNG_GIT_VERSION}" \
|
||||||
org.label-schema.url="${LABEL_VCS_URL}" \
|
org.label-schema.url="${LABEL_VCS_URL}" \
|
||||||
org.label-schema.vcs-ref=${LABEL_VCS_REF} \
|
org.label-schema.vcs-ref=${LABEL_VCS_REF} \
|
||||||
org.label-schema.vcs-url=${LABEL_VCS_URL} \
|
org.label-schema.vcs-url=${LABEL_VCS_URL} \
|
||||||
org.label-schema.build-date="${LABEL_DATE}" \
|
org.label-schema.build-date="${LABEL_DATE}" \
|
||||||
org.label-schema.usage="https://github.com/searxng/searxng-docker" \
|
org.label-schema.usage="https://github.com/searxng/searxng-docker" \
|
||||||
org.opencontainers.image.title="searxng" \
|
org.opencontainers.image.title="searxng" \
|
||||||
org.opencontainers.image.version="${SEARX_GIT_VERSION}" \
|
org.opencontainers.image.version="${SEARXNG_GIT_VERSION}" \
|
||||||
org.opencontainers.image.url="${LABEL_VCS_URL}" \
|
org.opencontainers.image.url="${LABEL_VCS_URL}" \
|
||||||
org.opencontainers.image.revision=${LABEL_VCS_REF} \
|
org.opencontainers.image.revision=${LABEL_VCS_REF} \
|
||||||
org.opencontainers.image.source=${LABEL_VCS_URL} \
|
org.opencontainers.image.source=${LABEL_VCS_URL} \
|
||||||
|
|
|
@ -17,7 +17,7 @@ Environment variables:
|
||||||
BIND_ADDRESS uwsgi bind to the specified TCP socket using HTTP protocol.
|
BIND_ADDRESS uwsgi bind to the specified TCP socket using HTTP protocol.
|
||||||
Default value: ${DEFAULT_BIND_ADDRESS}
|
Default value: ${DEFAULT_BIND_ADDRESS}
|
||||||
Volume:
|
Volume:
|
||||||
/etc/searx the docker entry point copies settings.yml and uwsgi.ini in
|
/etc/searxng the docker entry point copies settings.yml and uwsgi.ini in
|
||||||
this directory (see the -f command line option)"
|
this directory (see the -f command line option)"
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
@ -48,22 +48,22 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
get_searx_version(){
|
get_searxng_version(){
|
||||||
su searx -c \
|
su searxng -c \
|
||||||
'python3 -c "import six; import searx.version; six.print_(searx.version.VERSION_STRING)"' \
|
'python3 -c "import six; import searx.version; six.print_(searx.version.VERSION_STRING)"' \
|
||||||
2>/dev/null
|
2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
SEARX_VERSION="$(get_searx_version)"
|
SEARXNG_VERSION="$(get_searxng_version)"
|
||||||
export SEARX_VERSION
|
export SEARXNG_VERSION
|
||||||
echo "searx version ${SEARX_VERSION}"
|
echo "SearXNG version ${SEARXNG_VERSION}"
|
||||||
|
|
||||||
# helpers to update the configuration files
|
# helpers to update the configuration files
|
||||||
patch_uwsgi_settings() {
|
patch_uwsgi_settings() {
|
||||||
CONF="$1"
|
CONF="$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
patch_searx_settings() {
|
patch_searxng_settings() {
|
||||||
CONF="$1"
|
CONF="$1"
|
||||||
|
|
||||||
# Make sure that there is trailing slash at the end of BASE_URL
|
# Make sure that there is trailing slash at the end of BASE_URL
|
||||||
|
@ -114,7 +114,7 @@ update_conf() {
|
||||||
$PATCH_REF_CONF "${CONF}"
|
$PATCH_REF_CONF "${CONF}"
|
||||||
else
|
else
|
||||||
# Keep the current configuration
|
# Keep the current configuration
|
||||||
printf '⚠️ Check new version %s to make sure searx is working properly\n' "${NEW_CONF}"
|
printf '⚠️ Check new version %s to make sure SearXNG is working properly\n' "${NEW_CONF}"
|
||||||
cp "${REF_CONF}" "${NEW_CONF}"
|
cp "${REF_CONF}" "${NEW_CONF}"
|
||||||
$PATCH_REF_CONF "${NEW_CONF}"
|
$PATCH_REF_CONF "${NEW_CONF}"
|
||||||
fi
|
fi
|
||||||
|
@ -128,11 +128,35 @@ update_conf() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# make sure there are uwsgi settings
|
# searx compatibility: copy /etc/searx/* to /etc/searxng/*
|
||||||
update_conf "${FORCE_CONF_UPDATE}" "${UWSGI_SETTINGS_PATH}" "/usr/local/searx/dockerfiles/uwsgi.ini" "patch_uwsgi_settings"
|
SEARX_CONF=0
|
||||||
|
if [ -f "/etc/searx/settings.yml" ]; then
|
||||||
|
if [ ! -f "${SEARXNG_SETTINGS_PATH}" ]; then
|
||||||
|
printf '⚠️ /etc/searx/settings.yml is copied to /etc/searxng\n'
|
||||||
|
cp "/etc/searx/settings.yml" "${SEARXNG_SETTINGS_PATH}"
|
||||||
|
fi
|
||||||
|
SEARX_CONF=1
|
||||||
|
fi
|
||||||
|
if [ -f "/etc/searx/uwsgi.ini" ]; then
|
||||||
|
printf '⚠️ /etc/searx/uwsgi.ini is ignored. Use the volume /etc/searxng\n'
|
||||||
|
SEARX_CONF=1
|
||||||
|
fi
|
||||||
|
if [ "$SEARX_CONF" -eq "1" ]; then
|
||||||
|
printf '⚠️ The deprecated volume /etc/searx is mounted. Please update your configuration to use /etc/searxng ⚠️\n'
|
||||||
|
cat << EOF > /etc/searx/deprecated_volume_read_me.txt
|
||||||
|
This Docker image uses the volume /etc/searxng
|
||||||
|
Update your configuration:
|
||||||
|
* remove uwsgi.ini (or very carefully update your existing uwsgi.ini using https://github.com/searxng/searxng/blob/master/dockerfiles/uwsgi.ini )
|
||||||
|
* mount /etc/searxng instead of /etc/searx
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
# end of searx compatibility
|
||||||
|
|
||||||
# make sure there are searx settings
|
# make sure there are uwsgi settings
|
||||||
update_conf "${FORCE_CONF_UPDATE}" "${SEARXNG_SETTINGS_PATH}" "/usr/local/searx/searx/settings.yml" "patch_searx_settings"
|
update_conf "${FORCE_CONF_UPDATE}" "${UWSGI_SETTINGS_PATH}" "/usr/local/searxng/dockerfiles/uwsgi.ini" "patch_uwsgi_settings"
|
||||||
|
|
||||||
|
# make sure there are searxng settings
|
||||||
|
update_conf "${FORCE_CONF_UPDATE}" "${SEARXNG_SETTINGS_PATH}" "/usr/local/searxng/searx/settings.yml" "patch_searxng_settings"
|
||||||
|
|
||||||
# dry run (to update configuration files, then inspect them)
|
# dry run (to update configuration files, then inspect them)
|
||||||
if [ $DRY_RUN -eq 1 ]; then
|
if [ $DRY_RUN -eq 1 ]; then
|
||||||
|
@ -141,9 +165,9 @@ if [ $DRY_RUN -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch /var/run/uwsgi-logrotate
|
touch /var/run/uwsgi-logrotate
|
||||||
chown -R searx:searx /var/log/uwsgi /var/run/uwsgi-logrotate
|
chown -R searxng:searxng /var/log/uwsgi /var/run/uwsgi-logrotate
|
||||||
unset MORTY_KEY
|
unset MORTY_KEY
|
||||||
|
|
||||||
# Start uwsgi
|
# Start uwsgi
|
||||||
printf 'Listen on %s\n' "${BIND_ADDRESS}"
|
printf 'Listen on %s\n' "${BIND_ADDRESS}"
|
||||||
exec su-exec searx:searx uwsgi --master --http-socket "${BIND_ADDRESS}" "${UWSGI_SETTINGS_PATH}"
|
exec su-exec searxng:searxng uwsgi --master --http-socket "${BIND_ADDRESS}" "${UWSGI_SETTINGS_PATH}"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[uwsgi]
|
[uwsgi]
|
||||||
# Who will run the code
|
# Who will run the code
|
||||||
uid = searx
|
uid = searxng
|
||||||
gid = searx
|
gid = searxng
|
||||||
|
|
||||||
# Number of workers (usually CPU count)
|
# Number of workers (usually CPU count)
|
||||||
workers = 4
|
workers = 4
|
||||||
|
@ -20,8 +20,8 @@ enable-threads = true
|
||||||
module = searx.webapp
|
module = searx.webapp
|
||||||
|
|
||||||
# Virtualenv and python path
|
# Virtualenv and python path
|
||||||
pythonpath = /usr/local/searx/
|
pythonpath = /usr/local/searxng/
|
||||||
chdir = /usr/local/searx/searx/
|
chdir = /usr/local/searxng/searx/
|
||||||
|
|
||||||
# Disable logging for privacy
|
# Disable logging for privacy
|
||||||
disable-logging=True
|
disable-logging=True
|
||||||
|
@ -38,10 +38,10 @@ add-header = Connection: close
|
||||||
|
|
||||||
# uwsgi serves the static files
|
# uwsgi serves the static files
|
||||||
# expires set to one day as Flask does
|
# expires set to one day as Flask does
|
||||||
static-map = /static=/usr/local/searx/searx/static
|
static-map = /static=/usr/local/searxng/searx/static
|
||||||
static-expires = /* 864000
|
static-expires = /* 864000
|
||||||
static-gzip-all = True
|
static-gzip-all = True
|
||||||
offload-threads = %k
|
offload-threads = %k
|
||||||
|
|
||||||
# Cache
|
# Cache
|
||||||
cache2 = name=searxcache,items=2000,blocks=2000,blocksize=4096,bitmap=1
|
cache2 = name=searxngcache,items=2000,blocks=2000,blocksize=4096,bitmap=1
|
||||||
|
|
|
@ -63,7 +63,7 @@ instance using `docker run <https://docs.docker.com/engine/reference/run/>`_:
|
||||||
$ docker pull searxng/searxng
|
$ docker pull searxng/searxng
|
||||||
$ docker run --rm \
|
$ docker run --rm \
|
||||||
-d -p ${PORT}:8080 \
|
-d -p ${PORT}:8080 \
|
||||||
-v "${PWD}/searx:/etc/searx" \
|
-v "${PWD}/searxng:/etc/searxng" \
|
||||||
-e "BASE_URL=http://localhost:$PORT/" \
|
-e "BASE_URL=http://localhost:$PORT/" \
|
||||||
-e "INSTANCE_NAME=my-instance" \
|
-e "INSTANCE_NAME=my-instance" \
|
||||||
searxng/searxng
|
searxng/searxng
|
||||||
|
@ -75,7 +75,7 @@ Open your WEB browser and visit the URL:
|
||||||
|
|
||||||
$ xdg-open "http://localhost:$PORT"
|
$ xdg-open "http://localhost:$PORT"
|
||||||
|
|
||||||
Inside ``${PWD}/searx``, you will find ``settings.yml`` and ``uwsgi.ini``. You
|
Inside ``${PWD}/searxng``, you will find ``settings.yml`` and ``uwsgi.ini``. You
|
||||||
can modify these files according to your needs and restart the Docker image.
|
can modify these files according to your needs and restart the Docker image.
|
||||||
|
|
||||||
.. code:: sh
|
.. code:: sh
|
||||||
|
@ -139,7 +139,7 @@ Build the image
|
||||||
It's also possible to build SearXNG from the embedded :origin:`Dockerfile`::
|
It's also possible to build SearXNG from the embedded :origin:`Dockerfile`::
|
||||||
|
|
||||||
$ git clone https://github.com/searxng/searxng.git
|
$ git clone https://github.com/searxng/searxng.git
|
||||||
$ cd searx
|
$ cd searxng
|
||||||
$ make docker.build
|
$ make docker.build
|
||||||
...
|
...
|
||||||
Successfully built 49586c016434
|
Successfully built 49586c016434
|
||||||
|
|
18
manage
18
manage
|
@ -390,10 +390,10 @@ docker.buildx() {
|
||||||
docker.build() {
|
docker.build() {
|
||||||
pyenv.install
|
pyenv.install
|
||||||
|
|
||||||
local SEARX_GIT_VERSION
|
local SEARXNG_GIT_VERSION
|
||||||
local VERSION_GITCOMMIT
|
local VERSION_GITCOMMIT
|
||||||
local GITHUB_USER
|
local GITHUB_USER
|
||||||
local SEARX_IMAGE_NAME
|
local SEARXNG_IMAGE_NAME
|
||||||
local BUILD
|
local BUILD
|
||||||
|
|
||||||
build_msg DOCKER build
|
build_msg DOCKER build
|
||||||
|
@ -427,35 +427,35 @@ docker.build() {
|
||||||
|
|
||||||
# define the docker image name
|
# define the docker image name
|
||||||
GITHUB_USER=$(echo "${GIT_URL}" | sed 's/.*github\.com\/\([^\/]*\).*/\1/')
|
GITHUB_USER=$(echo "${GIT_URL}" | sed 's/.*github\.com\/\([^\/]*\).*/\1/')
|
||||||
SEARX_IMAGE_NAME="${SEARX_IMAGE_NAME:-${GITHUB_USER:-searxng}/searxng}"
|
SEARXNG_IMAGE_NAME="${SEARXNG_IMAGE_NAME:-${GITHUB_USER:-searxng}/searxng}"
|
||||||
|
|
||||||
BUILD="build"
|
BUILD="build"
|
||||||
if [ "$1" = "buildx" ]; then
|
if [ "$1" = "buildx" ]; then
|
||||||
# buildx includes the push option
|
# buildx includes the push option
|
||||||
CACHE_TAG="${SEARX_IMAGE_NAME}:latest-build-cache"
|
CACHE_TAG="${SEARXNG_IMAGE_NAME}:latest-build-cache"
|
||||||
BUILD="buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push --cache-from=type=registry,ref=$CACHE_TAG --cache-to=type=registry,ref=$CACHE_TAG,mode=max"
|
BUILD="buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --push --cache-from=type=registry,ref=$CACHE_TAG --cache-to=type=registry,ref=$CACHE_TAG,mode=max"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
build_msg DOCKER "Build command: ${BUILD}"
|
build_msg DOCKER "Build command: ${BUILD}"
|
||||||
|
|
||||||
# build Docker image
|
# build Docker image
|
||||||
build_msg DOCKER "Building image ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}"
|
build_msg DOCKER "Building image ${SEARXNG_IMAGE_NAME}:${SEARXNG_GIT_VERSION}"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
docker $BUILD \
|
docker $BUILD \
|
||||||
--build-arg BASE_IMAGE="${DEPENDENCIES_IMAGE_NAME}" \
|
--build-arg BASE_IMAGE="${DEPENDENCIES_IMAGE_NAME}" \
|
||||||
--build-arg GIT_URL="${GIT_URL}" \
|
--build-arg GIT_URL="${GIT_URL}" \
|
||||||
--build-arg SEARX_GIT_VERSION="${VERSION_STRING}" \
|
--build-arg SEARXNG_GIT_VERSION="${VERSION_STRING}" \
|
||||||
--build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \
|
--build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \
|
||||||
--build-arg LABEL_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
|
--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_REF="$(git rev-parse HEAD)" \
|
||||||
--build-arg LABEL_VCS_URL="${GIT_URL}" \
|
--build-arg LABEL_VCS_URL="${GIT_URL}" \
|
||||||
--build-arg TIMESTAMP_SETTINGS="$(git log -1 --format="%cd" --date=unix -- searx/settings.yml)" \
|
--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)" \
|
--build-arg TIMESTAMP_UWSGI="$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini)" \
|
||||||
-t "${SEARX_IMAGE_NAME}:latest" -t "${SEARX_IMAGE_NAME}:${VERSION_STRING}" .
|
-t "${SEARXNG_IMAGE_NAME}:latest" -t "${SEARXNG_IMAGE_NAME}:${VERSION_STRING}" .
|
||||||
|
|
||||||
if [ "$1" = "push" ]; then
|
if [ "$1" = "push" ]; then
|
||||||
docker push "${SEARX_IMAGE_NAME}:latest"
|
docker push "${SEARXNG_IMAGE_NAME}:latest"
|
||||||
docker push "${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}"
|
docker push "${SEARXNG_IMAGE_NAME}:${SEARXNG_GIT_VERSION}"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
dump_return $?
|
dump_return $?
|
||||||
|
|
Loading…
Reference in New Issue