Dockerfile 5.0 KB

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