Dockerfile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. FROM python:3.8.13-slim-bullseye
  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. ENV GOSU_VERSION=1.12 \
  12. GOSU_SHA256=0f25a21cf64e58078057adc78f38705163c1d564a959ff30a891c31917011a54 \
  13. TINI_VERSION=0.19.0 \
  14. TINI_SHA256=93dcc18adc78c65a028a84799ecf8ad40c936fdfc5f2a57b1acda5a8117fa82c
  15. RUN set -x \
  16. && buildDeps=" \
  17. wget \
  18. " \
  19. && apt-get update && apt-get install -y --no-install-recommends $buildDeps \
  20. && rm -rf /var/lib/apt/lists/* \
  21. # grab gosu for easy step-down from root
  22. && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" \
  23. && echo "$GOSU_SHA256 /usr/local/bin/gosu" | sha256sum --check --status \
  24. && chmod +x /usr/local/bin/gosu \
  25. # grab tini for signal processing and zombie killing
  26. && wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini-amd64" \
  27. && echo "$TINI_SHA256 /usr/local/bin/tini" | sha256sum --check --status \
  28. && chmod +x /usr/local/bin/tini \
  29. && apt-get purge -y --auto-remove $buildDeps
  30. # Sane defaults for pip
  31. ENV \
  32. PIP_NO_CACHE_DIR=1 \
  33. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  34. # Sentry config params
  35. SENTRY_CONF=/etc/sentry \
  36. # Disable some unused uWSGI features, saving dependencies
  37. # Thank to https://stackoverflow.com/a/25260588/90297
  38. UWSGI_PROFILE_OVERRIDE=ssl=false;xml=false;routing=false \
  39. # UWSGI dogstatsd plugin
  40. UWSGI_NEED_PLUGIN=/var/lib/uwsgi/dogstatsd \
  41. # grpcio>1.30.0 requires this, see requirements.txt for more detail.
  42. GRPC_POLL_STRATEGY=epoll1
  43. # Install dependencies first to leverage Docker layer caching.
  44. COPY /dist/requirements-frozen.txt /tmp/requirements-frozen.txt
  45. RUN set -x \
  46. && buildDeps="" \
  47. # uwsgi-dogstatsd
  48. && buildDeps="$buildDeps \
  49. gcc \
  50. libpcre3-dev \
  51. wget \
  52. zlib1g-dev \
  53. " \
  54. # maxminddb
  55. && buildDeps="$buildDeps \
  56. libmaxminddb-dev \
  57. "\
  58. # xmlsec
  59. && buildDeps="$buildDeps \
  60. libxmlsec1-dev \
  61. pkg-config \
  62. " \
  63. && apt-get update \
  64. && apt-get install -y --no-install-recommends $buildDeps \
  65. && pip install -r /tmp/requirements-frozen.txt \
  66. && mkdir /tmp/uwsgi-dogstatsd \
  67. && wget -O - https://github.com/eventbrite/uwsgi-dogstatsd/archive/filters-and-tags.tar.gz | \
  68. tar -xzf - -C /tmp/uwsgi-dogstatsd --strip-components=1 \
  69. && UWSGI_NEED_PLUGIN="" uwsgi --build-plugin /tmp/uwsgi-dogstatsd \
  70. && mkdir -p /var/lib/uwsgi \
  71. && mv dogstatsd_plugin.so /var/lib/uwsgi/ \
  72. && rm -rf /tmp/requirements-frozen.txt /tmp/uwsgi-dogstatsd .uwsgi_plugins_builder \
  73. && apt-get purge -y --auto-remove $buildDeps \
  74. # We install run-time dependencies strictly after
  75. # build dependencies to prevent accidental collusion.
  76. # These are also installed last as they are needed
  77. # during container run and can have the same deps w/
  78. # build deps such as maxminddb.
  79. && apt-get install -y --no-install-recommends \
  80. # pillow
  81. libjpeg-dev \
  82. # rust bindings
  83. libffi-dev \
  84. # maxminddb bindings
  85. libmaxminddb-dev \
  86. # SAML needs these run-time
  87. libxmlsec1-dev \
  88. libxslt-dev \
  89. # pyyaml needs this run-time
  90. libyaml-dev \
  91. # other
  92. pkg-config \
  93. \
  94. && apt-get clean \
  95. && rm -rf /var/lib/apt/lists/* \
  96. # Fully verify that the C extension is correctly installed, it unfortunately
  97. # requires a full check into maxminddb.extension.Reader
  98. && python -c 'import maxminddb.extension; maxminddb.extension.Reader' \
  99. && mkdir -p $SENTRY_CONF
  100. COPY /dist/*.whl /tmp/dist/
  101. RUN pip install /tmp/dist/*.whl --no-deps && pip check && rm -rf /tmp/dist
  102. RUN sentry help | sed '1,/Commands:/d' | awk '{print $1}' > /sentry-commands.txt
  103. COPY ./docker/sentry.conf.py ./docker/config.yml $SENTRY_CONF/
  104. COPY ./docker/docker-entrypoint.sh /
  105. EXPOSE 9000
  106. VOLUME /data
  107. ENTRYPOINT exec /docker-entrypoint.sh "$0" "$@"
  108. CMD ["run", "web"]
  109. ARG SOURCE_COMMIT
  110. ENV SENTRY_BUILD=${SOURCE_COMMIT:-unknown}
  111. LABEL org.opencontainers.image.revision=$SOURCE_COMMIT
  112. LABEL org.opencontainers.image.source="https://github.com/getsentry/sentry/tree/${SOURCE_COMMIT:-master}/"
  113. LABEL org.opencontainers.image.licenses="https://github.com/getsentry/sentry/blob/${SOURCE_COMMIT:-master}/LICENSE"