Dockerfile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # syntax=docker/dockerfile:1
  2. # Builds omnisearch + libbeaker from upstream, then runs on a slim image.
  3. #
  4. # Notes:
  5. # - This repo is written in C and links against libbeaker (shared library).
  6. # - At runtime, libbeaker must be present in the dynamic linker path.
  7. # - The server binds to 0.0.0.0:8087 by default in example-config.ini.
  8. # --- build stage ---
  9. FROM debian:trixie AS build
  10. WORKDIR /src
  11. # Toolchain + headers for building omnisearch and beaker
  12. RUN apt-get update && apt-get install -y --no-install-recommends \
  13. ca-certificates \
  14. git \
  15. make \
  16. gcc \
  17. libc6-dev \
  18. libcurl4-openssl-dev \
  19. libxml2-dev \
  20. libssl-dev \
  21. && rm -rf /var/lib/apt/lists/*
  22. # Fetch and build/install beaker from upstream
  23. RUN git clone https://git.bwaaa.monster/beaker /tmp/beaker \
  24. && make -C /tmp/beaker \
  25. && make -C /tmp/beaker install \
  26. && rm -rf /tmp/beaker
  27. # Copy omnisearch source
  28. COPY . .
  29. # Build omnisearch (produces bin/omnisearch)
  30. RUN make
  31. # --- runtime stage ---
  32. FROM debian:trixie-slim AS runtime
  33. WORKDIR /app
  34. # Runtime shared libs + TLS roots
  35. RUN apt-get update && apt-get install -y --no-install-recommends \
  36. ca-certificates \
  37. libcurl4 \
  38. libxml2 \
  39. libssl3 \
  40. && rm -rf /var/lib/apt/lists/*
  41. # Copy binary + assets
  42. COPY --from=build /src/bin/omnisearch /usr/local/bin/omnisearch
  43. COPY --from=build /src/templates /app/templates
  44. COPY --from=build /src/static /app/static
  45. COPY --from=build /src/example-config.ini /app/config.ini
  46. # Bundle libbeaker from build stage and register likely library directories with the dynamic loader.
  47. # Don't assume an exact SONAME/filename (it might be libbeaker.so.0, etc) or install location.
  48. COPY --from=build /usr/local/lib/libbeaker.so* /usr/local/lib/
  49. COPY --from=build /usr/lib/libbeaker.so* /usr/lib/
  50. COPY --from=build /usr/lib/*-linux-gnu/libbeaker.so* /usr/lib/
  51. RUN set -eux; \
  52. echo "/usr/local/lib" > /etc/ld.so.conf.d/omnisearch.conf; \
  53. echo "/usr/lib" >> /etc/ld.so.conf.d/omnisearch.conf; \
  54. echo "/usr/lib/x86_64-linux-gnu" >> /etc/ld.so.conf.d/omnisearch.conf; \
  55. echo "=== libbeaker debug listing ==="; \
  56. (ls -la /usr/local/lib | grep -i beaker) || true; \
  57. (ls -la /usr/lib | grep -i beaker) || true; \
  58. (ls -la /usr/lib/x86_64-linux-gnu | grep -i beaker) || true; \
  59. # Ensure an unversioned libbeaker.so exists somewhere in the loader path. \
  60. # Some installs only provide versioned files (libbeaker.so.0 / libbeaker.so.0.0.0). \
  61. if ! [ -e /usr/local/lib/libbeaker.so ] && ! [ -e /usr/lib/libbeaker.so ] && ! [ -e /usr/lib/x86_64-linux-gnu/libbeaker.so ]; then \
  62. v="$({ ls -1 /usr/local/lib/libbeaker.so.* /usr/lib/libbeaker.so.* /usr/lib/x86_64-linux-gnu/libbeaker.so.* 2>/dev/null || true; } | head -n1)"; \
  63. if [ -z "$v" ]; then \
  64. echo "ERROR: libbeaker not found in runtime image after COPY. Check build-stage install location."; \
  65. exit 1; \
  66. fi; \
  67. d="$(dirname "$v")"; \
  68. ln -s "$(basename "$v")" "$d/libbeaker.so"; \
  69. fi; \
  70. ldconfig
  71. # Run as non-root
  72. RUN useradd --system --home /app --shell /usr/sbin/nologin appuser \
  73. && chown -R appuser:appuser /app
  74. USER appuser
  75. EXPOSE 8087
  76. # Many setups read config.ini from the working directory.
  77. # If omnisearch uses an env var or CLI flag for config, adjust CMD accordingly.
  78. CMD ["omnisearch"]