Dockerfile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. FROM python:3.12.6-slim-bookworm
  2. LABEL maintainer="oss@sentry.io"
  3. LABEL org.opencontainers.image.title="Sentry"
  4. LABEL org.opencontainers.image.description="Sentry runtime image"
  5. LABEL org.opencontainers.image.url="https://sentry.io/"
  6. LABEL org.opencontainers.image.documentation="https://develop.sentry.dev/self-hosted/"
  7. LABEL org.opencontainers.image.vendor="Functional Software, Inc."
  8. LABEL org.opencontainers.image.authors="oss@sentry.io"
  9. # add our user and group first to make sure their IDs get assigned consistently
  10. RUN groupadd -r sentry && useradd -r -m -g sentry sentry
  11. RUN : \
  12. && apt-get update \
  13. && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  14. libexpat1 \
  15. && apt-get clean \
  16. && rm -rf /var/lib/apt/lists/*
  17. ARG GOSU_VERSION=1.17
  18. ARG GOSU_SHA256=bbc4136d03ab138b1ad66fa4fc051bafc6cc7ffae632b069a53657279a450de3
  19. ARG TINI_VERSION=0.19.0
  20. ARG TINI_SHA256=93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c
  21. RUN set -x \
  22. && buildDeps=" \
  23. wget \
  24. " \
  25. && apt-get update && apt-get install -y --no-install-recommends $buildDeps \
  26. && rm -rf /var/lib/apt/lists/* \
  27. # grab gosu for easy step-down from root
  28. && wget --quiet -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" \
  29. && echo "$GOSU_SHA256 /usr/local/bin/gosu" | sha256sum --check --status \
  30. && chmod +x /usr/local/bin/gosu \
  31. # grab tini for signal processing and zombie killing
  32. && wget --quiet -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-amd64" \
  33. && echo "$TINI_SHA256 /usr/local/bin/tini" | sha256sum --check --status \
  34. && chmod +x /usr/local/bin/tini \
  35. && apt-get purge -y --auto-remove $buildDeps
  36. WORKDIR /usr/src/sentry
  37. ENV PATH=/.venv/bin:$PATH PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
  38. RUN python3 -m venv /.venv
  39. ENV \
  40. # Sentry config params
  41. SENTRY_CONF=/etc/sentry \
  42. # UWSGI dogstatsd plugin
  43. UWSGI_NEED_PLUGIN=/var/lib/uwsgi/dogstatsd \
  44. # grpcio>1.30.0 requires this, see requirements.txt for more detail.
  45. GRPC_POLL_STRATEGY=epoll1
  46. # Install dependencies first to leverage Docker layer caching.
  47. COPY requirements-frozen.txt /tmp/requirements-frozen.txt
  48. RUN set -x \
  49. # uwsgi-dogstatsd
  50. && buildDeps=" \
  51. gcc \
  52. libpcre2-dev \
  53. wget \
  54. zlib1g-dev \
  55. " \
  56. && apt-get update \
  57. && apt-get install -y --no-install-recommends $buildDeps \
  58. && pip install -r /tmp/requirements-frozen.txt \
  59. && mkdir /tmp/uwsgi-dogstatsd \
  60. # pinned the same as in getsentry
  61. && wget -O - https://github.com/DataDog/uwsgi-dogstatsd/archive/1a04f784491ab0270b4e94feb94686b65d8d2db1.tar.gz | \
  62. tar -xzf - -C /tmp/uwsgi-dogstatsd --strip-components=1 \
  63. && UWSGI_NEED_PLUGIN="" uwsgi --build-plugin /tmp/uwsgi-dogstatsd \
  64. && mkdir -p /var/lib/uwsgi \
  65. && mv dogstatsd_plugin.so /var/lib/uwsgi/ \
  66. && rm -rf /tmp/requirements-frozen.txt /tmp/uwsgi-dogstatsd .uwsgi_plugins_builder \
  67. && apt-get purge -y --auto-remove $buildDeps \
  68. && apt-get clean \
  69. && rm -rf /var/lib/apt/lists/* \
  70. # Fully verify that the C extension is correctly installed, it unfortunately
  71. # requires a full check into maxminddb.extension.Reader
  72. && python -c 'import maxminddb.extension; maxminddb.extension.Reader' \
  73. && mkdir -p $SENTRY_CONF
  74. COPY . .
  75. RUN python3 -m tools.fast_editable --path .
  76. RUN sentry help | sed '1,/Commands:/d' | awk '{print $1}' > /sentry-commands.txt
  77. COPY ./self-hosted/sentry.conf.py ./self-hosted/config.yml $SENTRY_CONF/
  78. COPY ./self-hosted/docker-entrypoint.sh /
  79. RUN : double-check some built files are available \
  80. && test -f /usr/src/sentry/src/sentry/loader/_registry.json \
  81. && test -f /usr/src/sentry/src/sentry/integration-docs/python.json \
  82. && test -f /usr/src/sentry/src/sentry/static/sentry/dist/entrypoints/app.js \
  83. && sentry help \
  84. && :
  85. EXPOSE 9000
  86. VOLUME /data
  87. ENTRYPOINT exec /docker-entrypoint.sh "$0" "$@"
  88. CMD ["run", "web"]
  89. ARG SOURCE_COMMIT
  90. ENV SENTRY_BUILD=${SOURCE_COMMIT:-unknown}
  91. LABEL org.opencontainers.image.revision=$SOURCE_COMMIT
  92. LABEL org.opencontainers.image.source="https://github.com/getsentry/sentry/tree/${SOURCE_COMMIT:-master}/"
  93. LABEL org.opencontainers.image.licenses="https://github.com/getsentry/sentry/blob/${SOURCE_COMMIT:-master}/LICENSE"