Dockerfile 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. FROM python:2.7.16-slim-buster as sdist
  2. RUN apt-get update && apt-get install -y --no-install-recommends \
  3. # Needed for GPG
  4. dirmngr \
  5. gnupg \
  6. # Needed for fetching stuff
  7. wget \
  8. && rm -rf /var/lib/apt/lists/*
  9. # Fetch trusted keys
  10. RUN for key in \
  11. # gosu
  12. B42F6819007F00F88E364FD4036A9C25BF357DD4 \
  13. # tini
  14. 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
  15. # Node - gpg keys listed at https://github.com/nodejs/node
  16. 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  17. FD3A5288F042B6850C66B31F09FE44734EB7990E \
  18. 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  19. DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  20. C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  21. B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  22. 77984A986EBC2AA786BC0F66B01FBB92821C587A \
  23. 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
  24. 4ED778F539E3634C779C87C6D7062848A1AB005C \
  25. A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
  26. B9E2F5981AA6E0CD28160D9FF13993A75599653C \
  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. ENV GOSU_VERSION 1.11
  33. RUN set -x \
  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. ENV TINI_VERSION 0.18.0
  41. RUN set -x \
  42. && wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini" \
  43. && wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v$TINI_VERSION/tini.asc" \
  44. && gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
  45. && rm /usr/local/bin/tini.asc \
  46. && chmod +x /usr/local/bin/tini
  47. # Get and set up Node for front-end asset building
  48. COPY .nvmrc /usr/src/sentry/
  49. RUN cd /usr/src/sentry \
  50. && export NODE_VERSION="$(cat .nvmrc)" \
  51. && wget "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
  52. && wget "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
  53. && gpg --batch --verify SHASUMS256.txt.asc \
  54. && grep " node-v$NODE_VERSION-linux-x64.tar.gz\$" SHASUMS256.txt.asc | sha256sum -c - \
  55. && tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
  56. && rm -r "node-v$NODE_VERSION-linux-x64.tar.gz" SHASUMS256.txt.asc
  57. ARG SOURCE_COMMIT="unknown"
  58. ENV SENTRY_BUILD=$SOURCE_COMMIT
  59. COPY . /usr/src/sentry/
  60. RUN export YARN_CACHE_FOLDER="$(mktemp -d)" \
  61. && cd /usr/src/sentry \
  62. && python setup.py bdist_wheel \
  63. && rm -r "$YARN_CACHE_FOLDER" \
  64. && mv /usr/src/sentry/dist /dist
  65. # This is the image to be run
  66. FROM python:2.7.16-slim-buster
  67. # add our user and group first to make sure their IDs get assigned consistently
  68. RUN groupadd -r sentry && useradd -r -m -g sentry sentry
  69. COPY --from=sdist /usr/local/bin/gosu /usr/local/bin/tini /usr/local/bin/
  70. # Sane defaults for pip
  71. ENV PIP_NO_CACHE_DIR=off \
  72. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  73. PIP_USE_PEP517=off \
  74. # Sentry config params
  75. SENTRY_CONF=/etc/sentry \
  76. SENTRY_FILESTORE_DIR=/var/lib/sentry/files \
  77. # Disable some unused uWSGI features, saving dependencies
  78. # Thank to https://stackoverflow.com/a/25260588/90297
  79. UWSGI_PROFILE_OVERRIDE=ssl=false;xml=false;routing=false
  80. COPY --from=sdist /dist/*.whl /tmp/dist/
  81. RUN set -x \
  82. && buildDeps="" \
  83. # uwsgi
  84. && buildDeps="$buildDeps \
  85. gcc \
  86. g++ \
  87. " \
  88. # maxminddb
  89. && buildDeps="$buildDeps \
  90. libmaxminddb-dev \
  91. "\
  92. # librabbitmq
  93. && buildDeps="$buildDeps \
  94. make \
  95. " \
  96. && apt-get update \
  97. && apt-get install -y --no-install-recommends $buildDeps \
  98. && pip install /tmp/dist/*.whl \
  99. # Separate these due to https://git.io/fjyz6
  100. # Otherwise librabbitmq will install the latest amqp version,
  101. # violating kombu's amqp<2.0 constraint.
  102. && pip install librabbitmq==1.6.1 maxminddb==1.4.1 \
  103. && rm -rf /tmp/dist \
  104. && apt-get purge -y --auto-remove $buildDeps \
  105. # We install run-time dependencies strictly after
  106. # build dependencies to prevent accidental collusion.
  107. # These are also installed last as they are needed
  108. # during container run and can have the same deps w/
  109. # build deps such as maxminddb.
  110. && apt-get install -y --no-install-recommends \
  111. # pillow
  112. libjpeg-dev \
  113. # rust bindings
  114. libffi-dev \
  115. # maxminddb bindings
  116. libmaxminddb-dev \
  117. # SAML needs these run-time
  118. libxmlsec1-dev \
  119. libxslt-dev \
  120. # pyyaml needs this run-time
  121. libyaml-dev \
  122. # other
  123. pkg-config \
  124. \
  125. && apt-get clean \
  126. && rm -rf /var/lib/apt/lists/* \
  127. && python -c 'import librabbitmq' \
  128. # Fully verify that the C extension is correctly installed, it unfortunately
  129. # requires a full check into maxminddb.extension.Reader
  130. && python -c 'import maxminddb.extension; maxminddb.extension.Reader' \
  131. && mkdir -p $SENTRY_CONF && mkdir -p $SENTRY_FILESTORE_DIR
  132. COPY ./docker/docker-entrypoint.sh ./docker/sentry.conf.py ./docker/config.yml $SENTRY_CONF/
  133. EXPOSE 9000
  134. VOLUME /var/lib/sentry/files
  135. ENTRYPOINT exec $SENTRY_CONF/docker-entrypoint.sh $0 $@
  136. CMD ["run", "web"]