Dockerfile 3.2 KB

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