Dockerfile 4.9 KB

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