瀏覽代碼

Merge branch 'master' of https://github.com/asciimoo/searx

a01200356 9 年之前
父節點
當前提交
3bbdb23fd8
共有 2 個檔案被更改,包括 45 行新增16 行删除
  1. 43
    15
      Dockerfile
  2. 2
    1
      searx/__init__.py

+ 43
- 15
Dockerfile 查看文件

@@ -1,22 +1,50 @@
1
-FROM python:2.7-slim
1
+FROM alpine:3.3
2 2
 
3
-WORKDIR /app
3
+ENV BASE_URL=False IMAGE_PROXY=False
4
+EXPOSE 8888
5
+WORKDIR /usr/local/searx
6
+CMD ["./run.sh"]
4 7
 
5
-RUN useradd searx
8
+RUN adduser -D -h /usr/local/searx -s /bin/sh searx searx \
9
+ && echo '#!/bin/sh' >> run.sh \
10
+ && echo 'sed -i "s|base_url : False|base_url : $BASE_URL|g" searx/settings.yml' >> run.sh \
11
+ && echo 'sed -i "s/image_proxy : False/image_proxy : $IMAGE_PROXY/g" searx.setting.yml' >> run.sh \
12
+ && echo 'sed -i "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml' >> run.sh \
13
+ && echo 'python searx/webapp.py' >> run.sh \
14
+ && chmod +x run.sh
6 15
 
7
-EXPOSE 5000
8
-CMD ["/usr/local/bin/uwsgi", "--uid", "searx", "--gid", "searx", "--http", ":5000", "-w",  "searx.webapp"]
16
+COPY requirements.txt .
9 17
 
10
-RUN apt-get update && \
11
-    apt-get install -y --no-install-recommends \
12
-            zlib1g-dev libxml2-dev libxslt1-dev libffi-dev build-essential \
13
-            libssl-dev openssl && \
14
-    rm -rf /var/lib/apt/lists/*
18
+RUN apk -U add \
19
+    build-base \
20
+    python \
21
+    python-dev \
22
+    py-pip \
23
+    libxml2 \
24
+    libxml2-dev \
25
+    libxslt \
26
+    libxslt-dev \
27
+    libffi-dev \
28
+    openssl \
29
+    openssl-dev \
30
+    ca-certificates \
31
+ && pip install --no-cache -r requirements.txt \
32
+ && apk del \
33
+    build-base \
34
+    python-dev \
35
+    py-pip\
36
+    libffi-dev \
37
+    openssl-dev \
38
+    libxslt-dev \
39
+    libxml2-dev \
40
+    openssl-dev \
41
+    ca-certificates \
42
+ && rm -f /var/cache/apk/*
15 43
 
16
-RUN pip install --no-cache uwsgi
44
+COPY . .
17 45
 
18
-COPY requirements.txt /app/requirements.txt
19
-RUN pip install --no-cache -r requirements.txt
46
+RUN chown -R searx:searx *
20 47
 
21
-COPY . /app
22
-RUN sed -i -e "s/ultrasecretkey/`openssl rand -hex 16`/g" searx/settings.yml
48
+USER searx
49
+
50
+RUN sed -i "s/127.0.0.1/0.0.0.0/g" searx/settings.yml

+ 2
- 1
searx/__init__.py 查看文件

@@ -52,7 +52,8 @@ logger = logging.getLogger('searx')
52 52
 # Workaround for openssl versions <1.0.2
53 53
 # https://github.com/certifi/python-certifi/issues/26
54 54
 if OPENSSL_VERSION_INFO[0:3] < (1, 0, 2):
55
-    environ['REQUESTS_CA_BUNDLE'] = certifi.old_where()
55
+    if hasattr(certifi, 'old_where'):
56
+        environ['REQUESTS_CA_BUNDLE'] = certifi.old_where()
56 57
     logger.warning('You are using an old openssl version({0}), please upgrade above 1.0.2!'.format(OPENSSL_VERSION))
57 58
 
58 59
 logger.info('Initialisation done')