Dockerfile 7.0 KB

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