Dockerfile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. FROM python:2.7.16-slim-buster as sdist
  2. LABEL maintainer="oss@sentry.io"
  3. LABEL org.opencontainers.image.title="Sentry PyPI Wheel"
  4. LABEL org.opencontainers.image.description="PyPI Wheel Builder for Sentry"
  5. LABEL org.opencontainers.image.url="https://sentry.io/"
  6. LABEL org.opencontainers.image.source="https://github.com/getsentry/sentry"
  7. LABEL org.opencontainers.image.vendor="Functional Software, Inc."
  8. LABEL org.opencontainers.image.authors="oss@sentry.io"
  9. RUN apt-get update && apt-get install -y --no-install-recommends \
  10. # Needed for GPG
  11. dirmngr \
  12. gnupg \
  13. # Needed for fetching stuff
  14. wget \
  15. && rm -rf /var/lib/apt/lists/*
  16. # Fetch trusted keys
  17. RUN for key in \
  18. # gosu
  19. B42F6819007F00F88E364FD4036A9C25BF357DD4 \
  20. # tini
  21. 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
  22. # Node - gpg keys listed at https://github.com/nodejs/node
  23. 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  24. FD3A5288F042B6850C66B31F09FE44734EB7990E \
  25. 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  26. DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  27. C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  28. B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  29. 77984A986EBC2AA786BC0F66B01FBB92821C587A \
  30. 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
  31. 4ED778F539E3634C779C87C6D7062848A1AB005C \
  32. A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
  33. B9E2F5981AA6E0CD28160D9FF13993A75599653C \
  34. ; do \
  35. # TODO(byk): Replace the keyserver below w/ something owned by Sentry
  36. gpg --batch --keyserver hkps://mattrobenolt-keyserver.global.ssl.fastly.net:443 --recv-keys "$key"; \
  37. done
  38. # grab gosu for easy step-down from root
  39. ENV GOSU_VERSION 1.11
  40. RUN set -x \
  41. && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
  42. && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
  43. && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
  44. && rm -r /usr/local/bin/gosu.asc \
  45. && chmod +x /usr/local/bin/gosu
  46. # grab tini for signal processing and zombie killing
  47. ENV TINI_VERSION 0.18.0
  48. RUN set -x \
  49. && wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini" \
  50. && wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini.asc" \
  51. && gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
  52. && rm /usr/local/bin/tini.asc \
  53. && chmod +x /usr/local/bin/tini
  54. # Get and set up Node for front-end asset building
  55. COPY .nvmrc /usr/src/sentry/
  56. RUN cd /usr/src/sentry \
  57. && export NODE_VERSION="$(cat .nvmrc)" \
  58. && wget "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
  59. && wget "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
  60. && gpg --batch --verify SHASUMS256.txt.asc \
  61. && grep " node-v$NODE_VERSION-linux-x64.tar.gz\$" SHASUMS256.txt.asc | sha256sum -c - \
  62. && tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
  63. && rm -r "node-v$NODE_VERSION-linux-x64.tar.gz" SHASUMS256.txt.asc
  64. ARG SOURCE_COMMIT
  65. ENV SENTRY_BUILD=${SOURCE_COMMIT:-unknown}
  66. LABEL org.opencontainers.image.revision=$SOURCE_COMMIT
  67. LABEL org.opencontainers.image.licenses="https://github.com/getsentry/sentry/blob/${SOURCE_COMMIT:-master}/LICENSE"
  68. COPY . /usr/src/sentry/
  69. RUN export YARN_CACHE_FOLDER="$(mktemp -d)" \
  70. && cd /usr/src/sentry \
  71. && python setup.py bdist_wheel \
  72. && rm -r "$YARN_CACHE_FOLDER" \
  73. && mv /usr/src/sentry/dist /dist
  74. # This is the image to be run
  75. FROM python:2.7.16-slim-buster
  76. LABEL maintainer="oss@sentry.io"
  77. LABEL org.opencontainers.image.title="Sentry"
  78. LABEL org.opencontainers.image.description="Sentry runtime image"
  79. LABEL org.opencontainers.image.url="https://sentry.io/"
  80. LABEL org.opencontainers.image.documentation="https://github.com/getsentry/onpremise/tree/v10"
  81. LABEL org.opencontainers.image.source="https://github.com/getsentry/sentry"
  82. LABEL org.opencontainers.image.vendor="Functional Software, Inc."
  83. LABEL org.opencontainers.image.authors="oss@sentry.io"
  84. # add our user and group first to make sure their IDs get assigned consistently
  85. RUN groupadd -r sentry && useradd -r -m -g sentry sentry
  86. COPY --from=sdist /usr/local/bin/gosu /usr/local/bin/tini /usr/local/bin/
  87. # Sane defaults for pip
  88. ENV PIP_NO_CACHE_DIR=off \
  89. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  90. # Sentry config params
  91. SENTRY_CONF=/etc/sentry \
  92. SENTRY_FILESTORE_DIR=/var/lib/sentry/files \
  93. # Disable some unused uWSGI features, saving dependencies
  94. # Thank to https://stackoverflow.com/a/25260588/90297
  95. UWSGI_PROFILE_OVERRIDE=ssl=false;xml=false;routing=false \
  96. # UWSGI dogstatsd plugin
  97. UWSGI_NEED_PLUGIN=/var/lib/uwsgi/dogstatsd
  98. COPY --from=sdist /dist/*.whl /tmp/dist/
  99. RUN set -x \
  100. && buildDeps="" \
  101. # uwsgi
  102. && buildDeps="$buildDeps \
  103. gcc \
  104. g++ \
  105. wget \
  106. " \
  107. # maxminddb
  108. && buildDeps="$buildDeps \
  109. libmaxminddb-dev \
  110. "\
  111. # librabbitmq
  112. && buildDeps="$buildDeps \
  113. make \
  114. " \
  115. # xmlsec
  116. && buildDeps="$buildDeps \
  117. libxmlsec1-dev \
  118. pkg-config \
  119. " \
  120. && apt-get update \
  121. && apt-get install -y --no-install-recommends $buildDeps \
  122. && pip install /tmp/dist/*.whl \
  123. # Separate these due to https://git.io/fjyz6
  124. # Otherwise librabbitmq will install the latest amqp version,
  125. # violating kombu's amqp<2.0 constraint.
  126. && pip install librabbitmq==1.6.1 \
  127. && mkdir /tmp/uwsgi-dogstatsd \
  128. && wget -O - https://github.com/eventbrite/uwsgi-dogstatsd/archive/filters-and-tags.tar.gz | \
  129. tar -xzf - -C /tmp/uwsgi-dogstatsd --strip-components=1 \
  130. && UWSGI_NEED_PLUGIN="" uwsgi --build-plugin /tmp/uwsgi-dogstatsd \
  131. && mkdir -p /var/lib/uwsgi \
  132. && mv dogstatsd_plugin.so /var/lib/uwsgi/ \
  133. && rm -rf /tmp/dist /tmp/uwsgi-dogstatsd .uwsgi_plugins_builder \
  134. && apt-get purge -y --auto-remove $buildDeps \
  135. # We install run-time dependencies strictly after
  136. # build dependencies to prevent accidental collusion.
  137. # These are also installed last as they are needed
  138. # during container run and can have the same deps w/
  139. # build deps such as maxminddb.
  140. && apt-get install -y --no-install-recommends \
  141. # pillow
  142. libjpeg-dev \
  143. # rust bindings
  144. libffi-dev \
  145. # maxminddb bindings
  146. libmaxminddb-dev \
  147. # SAML needs these run-time
  148. libxmlsec1-dev \
  149. libxslt-dev \
  150. # pyyaml needs this run-time
  151. libyaml-dev \
  152. # other
  153. pkg-config \
  154. \
  155. && apt-get clean \
  156. && rm -rf /var/lib/apt/lists/* \
  157. && python -c 'import librabbitmq' \
  158. # Fully verify that the C extension is correctly installed, it unfortunately
  159. # requires a full check into maxminddb.extension.Reader
  160. && python -c 'import maxminddb.extension; maxminddb.extension.Reader' \
  161. && mkdir -p $SENTRY_CONF && mkdir -p $SENTRY_FILESTORE_DIR
  162. COPY ./docker/docker-entrypoint.sh ./docker/sentry.conf.py ./docker/config.yml $SENTRY_CONF/
  163. EXPOSE 9000
  164. VOLUME /var/lib/sentry/files
  165. ENTRYPOINT exec $SENTRY_CONF/docker-entrypoint.sh $0 $@
  166. CMD ["run", "web"]
  167. ARG SOURCE_COMMIT
  168. LABEL org.opencontainers.image.revision=$SOURCE_COMMIT
  169. LABEL org.opencontainers.image.licenses="https://github.com/getsentry/sentry/blob/${SOURCE_COMMIT:-master}/LICENSE"