Dockerfile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. # Readd on #4707 "--mount=type=cache,id=pip,target=/root/.cache/pip"
  16. RUN python -m venv ./venv \
  17. && . ./venv/bin/activate \
  18. && pip install -r requirements.txt \
  19. && pip install "uwsgi~=2.0"
  20. COPY ./searx/ ./searx/
  21. ARG TIMESTAMP_SETTINGS=0
  22. ARG TIMESTAMP_UWSGI=0
  23. RUN python -m compileall -q searx \
  24. && touch -c --date=@$TIMESTAMP_SETTINGS ./searx/settings.yml \
  25. && touch -c --date=@$TIMESTAMP_UWSGI ./dockerfiles/uwsgi.ini \
  26. && find /usr/local/searxng/searx/static \
  27. \( -name '*.html' -o -name '*.css' -o -name '*.js' -o -name '*.svg' -o -name '*.ttf' -o -name '*.eot' \) \
  28. -type f -exec gzip -9 -k {} + -exec brotli --best {} +
  29. ARG SEARXNG_UID=977
  30. ARG SEARXNG_GID=977
  31. RUN grep -m1 root /etc/group > /tmp/.searxng.group \
  32. && grep -m1 root /etc/passwd > /tmp/.searxng.passwd \
  33. && echo "searxng:x:$SEARXNG_GID:" >> /tmp/.searxng.group \
  34. && echo "searxng:x:$SEARXNG_UID:$SEARXNG_GID:searxng:/usr/local/searxng:/bin/bash" >> /tmp/.searxng.passwd
  35. FROM docker.io/library/python:3.13-slim
  36. RUN apt-get update \
  37. && apt-get install -y --no-install-recommends \
  38. # healthcheck
  39. wget \
  40. # uwsgi
  41. libpcre3 \
  42. libxml2 \
  43. mailcap \
  44. && rm -rf /var/lib/apt/lists/*
  45. COPY --chown=root:root --from=builder /tmp/.searxng.passwd /etc/passwd
  46. COPY --chown=root:root --from=builder /tmp/.searxng.group /etc/group
  47. ARG LABEL_DATE="0001-01-01T00:00:00Z"
  48. ARG GIT_URL="unspecified"
  49. ARG SEARXNG_GIT_VERSION="unspecified"
  50. ARG LABEL_VCS_REF="unspecified"
  51. ARG LABEL_VCS_URL="unspecified"
  52. WORKDIR /usr/local/searxng/
  53. COPY --chown=searxng:searxng --from=builder /usr/local/searxng/venv/ ./venv/
  54. COPY --chown=searxng:searxng --from=builder /usr/local/searxng/searx/ ./searx/
  55. COPY --chown=searxng:searxng ./dockerfiles/ ./dockerfiles/
  56. LABEL org.opencontainers.image.authors="searxng <$GIT_URL>" \
  57. org.opencontainers.image.created=$LABEL_DATE \
  58. org.opencontainers.image.description="A privacy-respecting, hackable metasearch engine" \
  59. org.opencontainers.image.documentation="https://github.com/searxng/searxng-docker" \
  60. org.opencontainers.image.licenses="AGPL-3.0-or-later" \
  61. org.opencontainers.image.revision=$LABEL_VCS_REF \
  62. org.opencontainers.image.source=$LABEL_VCS_URL \
  63. org.opencontainers.image.title="searxng" \
  64. org.opencontainers.image.url=$LABEL_VCS_URL \
  65. org.opencontainers.image.version=$SEARXNG_GIT_VERSION
  66. ENV CONFIG_PATH=/etc/searxng \
  67. DATA_PATH=/var/cache/searxng
  68. ENV SEARXNG_VERSION=$SEARXNG_GIT_VERSION \
  69. INSTANCE_NAME=searxng \
  70. AUTOCOMPLETE="" \
  71. BASE_URL="" \
  72. BIND_ADDRESS=[::]:8080 \
  73. MORTY_KEY="" \
  74. MORTY_URL="" \
  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/dockerfiles/docker-entrypoint.sh"]