commit 226932a929bc1f28b26719dcd4e40a6506b5dc41 Author: Knut Ahlers Date: Sun Jul 14 14:23:07 2019 +0200 Initial version diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2981bfc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3-alpine + +ENV INSTALL_DIR=/opt/searx \ + VERSION=v0.15.0 + +COPY build.sh /usr/local/bin + +RUN set -ex \ + && apk --no-cache add \ + bash \ + && bash /usr/local/bin/build.sh + +COPY run.sh /usr/local/bin + +WORKDIR /opt/searx +EXPOSE 8888 + +ENTRYPOINT ["bash"] +CMD ["/usr/local/bin/run.sh"] diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..77438aa --- /dev/null +++ b/build.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -euxo pipefail + +build_packages=( + curl + git + build-base + libffi-dev + libxml2-dev + libxslt-dev + openssl-dev +) + +dep_packages=( + libffi + libxml2 + libxslt + openssl +) + +apk --no-cache add "${build_packages[@]}" "${dep_packages[@]}" + +curl -sSfLo /usr/local/bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64" +chmod +x /usr/local/bin/dumb-init + +mkdir -p "$(dirname "${INSTALL_DIR}")" +git clone "https://github.com/asciimoo/searx.git" "${INSTALL_DIR}" + +pushd "${INSTALL_DIR}" + +git reset --hard "${VERSION}" +git clean -fdx +sh manage.sh update_packages + +sed -i 's/bind_address : "127.0.0.1"/bind_address : "0.0.0.0"/' searx/settings.yml + +popd + +apk --no-cache del "${build_packages[@]}" diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..95cb31b --- /dev/null +++ b/run.sh @@ -0,0 +1,17 @@ +#!/usr/local/bin/dumb-init /bin/bash +set -euo pipefail + +SECRET_KEY=${SECRET_KEY:-} +[[ -n ${SECRET_KEY} ]] || { + SECRET_KEY=$(openssl rand -hex 32) + echo "Attention: Secret key was auto-generated! You should" + echo "set it via SECRET_KEY env var to keep it persistent" +} + +[[ -z ${BASE_URL:-} ]] || { + sed -i "s@base_url : False@base_url : '${BASE_URL}'@" searx/settings.yml +} + +sed -i "s/secret_key : \"ultrasecretkey\"/secret_key : '${SECRET_KEY}'/" searx/settings.yml + +exec python searx/webapp.py