Dockerfile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. FROM docker.io/library/python:3.13-slim AS builder
  2. RUN apt-get update \
  3. && apt-get install -y --no-install-recommends \
  4. build-essential \
  5. brotli \
  6. # lxml
  7. libxml2-dev \
  8. libxslt1-dev \
  9. zlib1g-dev \
  10. # uwsgi
  11. libpcre3-dev \
  12. && rm -rf /var/lib/apt/lists/*
  13. WORKDIR /usr/local/searxng/
  14. COPY ./requirements.txt ./requirements.txt
  15. RUN --mount=type=cache,id=pip,target=/root/.cache/pip python -m venv ./venv \
  16. && . ./venv/bin/activate \
  17. && pip install -r requirements.txt \
  18. && pip install "uwsgi~=2.0"
  19. COPY ./searx/ ./searx/
  20. ARG TIMESTAMP_SETTINGS=0
  21. RUN python -m compileall -q searx \
  22. && touch -c --date=@$TIMESTAMP_SETTINGS ./searx/settings.yml \
  23. && find /usr/local/searxng/searx/static \
  24. \( -name '*.html' -o -name '*.css' -o -name '*.js' -o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
  25. -type f -exec gzip -9 -k {} + -exec brotli --best {} +
  26. ARG SEARXNG_UID=977
  27. ARG SEARXNG_GID=977
  28. RUN grep -m1 root /etc/group > /tmp/.searxng.group \
  29. && grep -m1 root /etc/passwd > /tmp/.searxng.passwd \
  30. && echo "searxng:x:$SEARXNG_GID:" >> /tmp/.searxng.group \
  31. && echo "searxng:x:$SEARXNG_UID:$SEARXNG_GID:searxng:/usr/local/searxng:/bin/bash" >> /tmp/.searxng.passwd
  32. FROM docker.io/library/python:3.13-slim
  33. RUN apt-get update \
  34. && apt-get install -y --no-install-recommends \
  35. # healthcheck
  36. wget \
  37. # lxml (ARMv7)
  38. libxslt1.1 \
  39. # uwsgi
  40. libpcre3 \
  41. libxml2 \
  42. mailcap \
  43. && rm -rf /var/lib/apt/lists/*
  44. COPY --chown=root:root --from=builder /tmp/.searxng.passwd /etc/passwd
  45. COPY --chown=root:root --from=builder /tmp/.searxng.group /etc/group
  46. ARG LABEL_DATE="0001-01-01T00:00:00Z"
  47. ARG GIT_URL="unspecified"
  48. ARG SEARXNG_GIT_VERSION="unspecified"
  49. ARG LABEL_VCS_REF="unspecified"
  50. ARG LABEL_VCS_URL="unspecified"
  51. WORKDIR /usr/local/searxng/
  52. COPY --chown=searxng:searxng --from=builder /usr/local/searxng/venv/ ./venv/
  53. COPY --chown=searxng:searxng --from=builder /usr/local/searxng/searx/ ./searx/
  54. COPY --chown=searxng:searxng ./container/config/ ./.template/
  55. COPY --chown=searxng:searxng ./container/entrypoint.sh ./entrypoint.sh
  56. ARG TIMESTAMP_UWSGI="0"
  57. RUN touch -c --date=@$TIMESTAMP_UWSGI ./.template/uwsgi.ini
  58. LABEL org.opencontainers.image.authors="searxng <$GIT_URL>" \
  59. org.opencontainers.image.created=$LABEL_DATE \
  60. org.opencontainers.image.description="A privacy-respecting, hackable metasearch engine" \
  61. org.opencontainers.image.documentation="https://github.com/searxng/searxng-docker" \
  62. org.opencontainers.image.licenses="AGPL-3.0-or-later" \
  63. org.opencontainers.image.revision=$LABEL_VCS_REF \
  64. org.opencontainers.image.source=$LABEL_VCS_URL \
  65. org.opencontainers.image.title="searxng" \
  66. org.opencontainers.image.url=$LABEL_VCS_URL \
  67. org.opencontainers.image.version=$SEARXNG_GIT_VERSION
  68. ENV CONFIG_PATH=/etc/searxng \
  69. DATA_PATH=/var/cache/searxng
  70. ENV SEARXNG_VERSION=$SEARXNG_GIT_VERSION \
  71. INSTANCE_NAME=searxng \
  72. AUTOCOMPLETE="" \
  73. BASE_URL="" \
  74. BIND_ADDRESS=[::]:8080 \
  75. SEARXNG_SETTINGS_PATH=$CONFIG_PATH/settings.yml \
  76. UWSGI_SETTINGS_PATH=$CONFIG_PATH/uwsgi.ini \
  77. UWSGI_WORKERS=%k \
  78. UWSGI_THREADS=4
  79. VOLUME $CONFIG_PATH
  80. VOLUME $DATA_PATH
  81. EXPOSE 8080
  82. HEALTHCHECK CMD wget --quiet --tries=1 --spider http://localhost:8080/healthz || exit 1
  83. ENTRYPOINT ["/usr/local/searxng/entrypoint.sh"]