Merge branch 'benbusby:main' into main

This commit is contained in:
Albony Cal 2021-12-20 09:52:11 +05:30 committed by GitHub
commit 1bd1946804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 38 deletions

View File

@ -1,64 +1,57 @@
FROM python:3.8-slim as builder
FROM python:3.8-alpine as builder
RUN apt-get update && apt-get install -y \
build-essential \
RUN apk --update add \
build-base \
libxml2-dev \
libxslt-dev \
libssl-dev \
openssl-dev \
libffi-dev
COPY requirements.txt .
RUN pip install --prefix /install --no-warn-script-location --no-cache-dir -r requirements.txt
FROM python:3.8-slim
FROM python:3.8-alpine
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
tor \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --update --no-cache tor curl bash openrc
# libcurl4-openssl-dev
ARG config_dir=/config
RUN mkdir -p $config_dir
VOLUME $config_dir
ENV CONFIG_VOLUME=$config_dir
ARG username=''
ENV WHOOGLE_USER=$username
ARG password=''
ENV WHOOGLE_PASS=$password
ARG proxyuser=''
ENV WHOOGLE_PROXY_USER=$proxyuser
ARG proxypass=''
ENV WHOOGLE_PROXY_PASS=$proxypass
ARG proxytype=''
ENV WHOOGLE_PROXY_TYPE=$proxytype
ARG proxyloc=''
ENV WHOOGLE_PROXY_LOC=$proxyloc
ARG whoogle_dotenv=''
ENV WHOOGLE_DOTENV=$whoogle_dotenv
ARG use_https=''
ENV HTTPS_ONLY=$use_https
ARG whoogle_port=5000
ENV EXPOSE_PORT=$whoogle_port
ARG twitter_alt='farside.link/nitter'
ENV WHOOGLE_ALT_TW=$twitter_alt
ARG youtube_alt='farside.link/invidious'
ENV WHOOGLE_ALT_YT=$youtube_alt
ARG instagram_alt='farside.link/bibliogram'
ENV WHOOGLE_ALT_IG=$instagram_alt
ARG reddit_alt='farside.link/libreddit'
ENV WHOOGLE_ALT_RD=$reddit_alt
ARG medium_alt='farside.link/scribe'
ENV WHOOGLE_ALT_MD=$medium_alt
ARG translate_alt='lingva.ml'
ENV WHOOGLE_ALT_TL=$translate_alt
ENV CONFIG_VOLUME=$config_dir \
WHOOGLE_USER=$username \
WHOOGLE_PASS=$password \
WHOOGLE_PROXY_USER=$proxyuser \
WHOOGLE_PROXY_PASS=$proxypass \
WHOOGLE_PROXY_TYPE=$proxytype \
WHOOGLE_PROXY_LOC=$proxyloc \
WHOOGLE_DOTENV=$whoogle_dotenv \
HTTPS_ONLY=$use_https \
EXPOSE_PORT=$whoogle_port \
WHOOGLE_ALT_TW=$twitter_alt \
WHOOGLE_ALT_YT=$youtube_alt \
WHOOGLE_ALT_IG=$instagram_alt \
WHOOGLE_ALT_RD=$reddit_alt \
WHOOGLE_ALT_MD=$medium_alt \
WHOOGLE_ALT_TL=$translate_alt
WORKDIR /whoogle

View File

@ -179,7 +179,7 @@ pip install -r requirements.txt
See the [available environment variables](#environment-variables) for additional configuration.
#### systemd Configuration
After building the virtual environment, you can add the following to `/lib/systemd/system/whoogle.service` to set up a Whoogle Search systemd service:
After building the virtual environment, you can add something like the following to `/lib/systemd/system/whoogle.service` to set up a Whoogle Search systemd service:
```ini
[Unit]
@ -207,8 +207,14 @@ Description=Whoogle
#Environment=WHOOGLE_DOTENV=1
Type=simple
User=<username>
WorkingDirectory=<whoogle_directory>
ExecStart=<whoogle_directory>/venv/bin/python3 -um app --host 0.0.0.0 --port 5000
# If installed as a package, add:
ExecStart=<python_install_dir>/python3 <whoogle_install_dir>/whoogle-search --host 127.0.0.1 --port 5000
# For example:
# ExecStart=/usr/bin/python3 /home/my_username/.local/bin/whoogle-search --host 127.0.0.1 --port 5000
# Otherwise if running the app from source, add:
ExecStart=<whoogle_repo_dir>/run
# For example:
# ExecStart=/var/www/whoogle-search/run
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=3
@ -331,6 +337,7 @@ There are a few optional environment variables available for customizing a Whoog
| WHOOGLE_AUTOCOMPLETE | Controls visibility of autocomplete/search suggestions. Default on -- use '0' to disable |
| WHOOGLE_MINIMAL | Remove everything except basic result cards from all search queries. |
| WHOOGLE_CSP | Sets a default set of 'Content-Security-Policy' headers |
| WHOOGLE_RESULTS_PER_PAGE | Set the number of results per page |
### Config Environment Variables
These environment variables allow setting default config values, but can be overwritten manually by using the home page config menu. These allow a shortcut for destroying/rebuilding an instance to the same config state every time.

View File

@ -3,5 +3,9 @@
if [ "$(whoami)" != "root" ]; then
tor -f /etc/tor/torrc
else
service tor start
if (grep alpine /etc/os-release >/dev/null); then
rc-service tor start
else
service tor start
fi
fi

View File

@ -75,7 +75,7 @@ def test_block_results(client):
assert has_pinterest
demo_config['block'] = 'pinterest.com,help.pinterest.com'
demo_config['block'] = 'pinterest.com'
rv = client.post(f'/{Endpoint.config}', data=demo_config)
assert rv._status_code == 302
@ -83,7 +83,10 @@ def test_block_results(client):
assert rv._status_code == 200
for link in BeautifulSoup(rv.data, 'html.parser').find_all('a', href=True):
assert 'pinterest.com' not in urlparse(link['href']).netloc
result_site = urlparse(link['href']).netloc
if not result_site:
continue
assert result_site not in 'pinterest.com'
def test_recent_results(client):

View File

@ -61,6 +61,18 @@
# Search using GET requests only (exposes query in logs)
#WHOOGLE_CONFIG_GET_ONLY=1
# Remove everything except basic result cards from all search queries
#WHOOGLE_MINIMAL=0
# Set the number of results per page
#WHOOGLE_RESULTS_PER_PAGE=10
# Controls visibility of autocomplete/search suggestions
#WHOOGLE_AUTOCOMPLETE=1
# The port where Whoogle will be exposed
#EXPOSE_PORT=5000
# Set instance URL
#WHOOGLE_CONFIG_URL=https://<whoogle url>/