Dockerfile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # This is the image to be run
  2. FROM python:2.7.16-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://github.com/getsentry/onpremise/tree/v10"
  8. LABEL org.opencontainers.image.source="https://github.com/getsentry/sentry"
  9. LABEL org.opencontainers.image.vendor="Functional Software, Inc."
  10. LABEL org.opencontainers.image.authors="oss@sentry.io"
  11. # add our user and group first to make sure their IDs get assigned consistently
  12. RUN groupadd -r sentry && useradd -r -m -g sentry sentry
  13. ENV GOSU_VERSION=1.11 \
  14. TINI_VERSION=0.18.0
  15. RUN set -x \
  16. && buildDeps=" \
  17. dirmngr \
  18. gnupg \
  19. wget \
  20. " \
  21. && apt-get update && apt-get install -y --no-install-recommends $buildDeps \
  22. && rm -rf /var/lib/apt/lists/* \
  23. # Fetch trusted keys
  24. && for key in \
  25. # gosu
  26. B42F6819007F00F88E364FD4036A9C25BF357DD4 \
  27. # tini
  28. 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
  29. ; do \
  30. # TODO(byk): Replace the keyserver below w/ something owned by Sentry
  31. gpg --batch --keyserver hkps://mattrobenolt-keyserver.global.ssl.fastly.net:443 --recv-keys "$key"; \
  32. done \
  33. # grab gosu for easy step-down from root
  34. && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
  35. && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
  36. && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
  37. && rm -r /usr/local/bin/gosu.asc \
  38. && chmod +x /usr/local/bin/gosu \
  39. # grab tini for signal processing and zombie killing
  40. && wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini" \
  41. && wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini.asc" \
  42. && gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
  43. && rm /usr/local/bin/tini.asc \
  44. && chmod +x /usr/local/bin/tini \
  45. && apt-get purge -y --auto-remove $buildDeps
  46. # Sane defaults for pip
  47. ENV PIP_NO_CACHE_DIR=off \
  48. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  49. # Sentry config params
  50. SENTRY_CONF=/etc/sentry \
  51. # Disable some unused uWSGI features, saving dependencies
  52. # Thank to https://stackoverflow.com/a/25260588/90297
  53. UWSGI_PROFILE_OVERRIDE=ssl=false;xml=false;routing=false \
  54. # UWSGI dogstatsd plugin
  55. UWSGI_NEED_PLUGIN=/var/lib/uwsgi/dogstatsd
  56. # Copy and install dependencies first to leverage Docker layer caching.
  57. COPY /dist/requirements.txt /tmp/dist/requirements.txt
  58. RUN set -x \
  59. && buildDeps="" \
  60. # uwsgi
  61. && buildDeps="$buildDeps \
  62. gcc \
  63. g++ \
  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 && 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.licenses="https://github.com/getsentry/sentry/blob/${SOURCE_COMMIT:-master}/LICENSE"