Dockerfile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may not
  2. # use this file except in compliance with the License. You may obtain a copy of
  3. # the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations under
  11. # the License.
  12. FROM debian:stretch-slim
  13. LABEL maintainer="CouchDB Developers dev@couchdb.apache.org"
  14. # Add CouchDB user account to make sure the IDs are assigned consistently
  15. RUN groupadd -g 5984 -r couchdb && useradd -u 5984 -d /opt/couchdb -g couchdb couchdb
  16. # be sure GPG and apt-transport-https are available and functional
  17. RUN set -ex; \
  18. apt-get update; \
  19. apt-get install -y --no-install-recommends \
  20. apt-transport-https \
  21. ca-certificates \
  22. dirmngr \
  23. gnupg \
  24. ; \
  25. rm -rf /var/lib/apt/lists/*
  26. # grab gosu for easy step-down from root and tini for signal handling and zombie reaping
  27. # see https://github.com/apache/couchdb-docker/pull/28#discussion_r141112407
  28. ENV GOSU_VERSION 1.11
  29. ENV TINI_VERSION 0.18.0
  30. RUN set -ex; \
  31. \
  32. apt-get update; \
  33. apt-get install -y --no-install-recommends wget; \
  34. rm -rf /var/lib/apt/lists/*; \
  35. \
  36. dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
  37. \
  38. # install gosu
  39. wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$dpkgArch"; \
  40. wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
  41. export GNUPGHOME="$(mktemp -d)"; \
  42. echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf; \
  43. for server in $(shuf -e pgpkeys.mit.edu \
  44. ha.pool.sks-keyservers.net \
  45. hkp://p80.pool.sks-keyservers.net:80 \
  46. pgp.mit.edu) ; do \
  47. gpg --batch --keyserver $server --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \
  48. done; \
  49. gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
  50. rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
  51. chmod +x /usr/local/bin/gosu; \
  52. gosu nobody true; \
  53. \
  54. # install tini
  55. wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch"; \
  56. wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch.asc"; \
  57. export GNUPGHOME="$(mktemp -d)"; \
  58. echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf; \
  59. for server in $(shuf -e pgpkeys.mit.edu \
  60. ha.pool.sks-keyservers.net \
  61. hkp://p80.pool.sks-keyservers.net:80 \
  62. pgp.mit.edu) ; do \
  63. gpg --batch --keyserver $server --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
  64. done; \
  65. gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
  66. rm -rf "$GNUPGHOME" /usr/local/bin/tini.asc; \
  67. chmod +x /usr/local/bin/tini; \
  68. apt-get purge -y --auto-remove wget; \
  69. tini --version
  70. # http://docs.couchdb.org/en/latest/install/unix.html#installing-the-apache-couchdb-packages
  71. ENV GPG_COUCH_KEY \
  72. # gpg: key D401AB61: public key "Bintray (by JFrog) <bintray@bintray.com> imported
  73. 8756C4F765C9AC3CB6B85D62379CE192D401AB61
  74. RUN set -xe; \
  75. export GNUPGHOME="$(mktemp -d)"; \
  76. echo "disable-ipv6" >> ${GNUPGHOME}/dirmngr.conf; \
  77. for server in $(shuf -e pgpkeys.mit.edu \
  78. ha.pool.sks-keyservers.net \
  79. hkp://p80.pool.sks-keyservers.net:80 \
  80. pgp.mit.edu) ; do \
  81. gpg --batch --keyserver $server --recv-keys $GPG_COUCH_KEY && break || : ; \
  82. done; \
  83. gpg --batch --export $GPG_COUCH_KEY > /etc/apt/trusted.gpg.d/couchdb.gpg; \
  84. command -v gpgconf && gpgconf --kill all || :; \
  85. rm -rf "$GNUPGHOME"; \
  86. apt-key list
  87. ENV COUCHDB_VERSION 2.3.1
  88. RUN echo "deb https://apache.bintray.com/couchdb-deb stretch main" > /etc/apt/sources.list.d/couchdb.list
  89. # https://github.com/apache/couchdb-pkg/blob/master/debian/README.Debian
  90. RUN set -xe; \
  91. apt-get update; \
  92. \
  93. echo "couchdb couchdb/mode select none" | debconf-set-selections; \
  94. # we DO want recommends this time
  95. DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \
  96. couchdb="$COUCHDB_VERSION"~stretch \
  97. ; \
  98. # Undo symlinks to /var/log and /var/lib
  99. rmdir /var/lib/couchdb /var/log/couchdb; \
  100. rm /opt/couchdb/data /opt/couchdb/var/log; \
  101. mkdir -p /opt/couchdb/data /opt/couchdb/var/log; \
  102. chown couchdb:couchdb /opt/couchdb/data /opt/couchdb/var/log; \
  103. chmod 777 /opt/couchdb/data /opt/couchdb/var/log; \
  104. # Remove file that sets logging to a file
  105. rm /opt/couchdb/etc/default.d/10-filelog.ini; \
  106. rm -rf /var/lib/apt/lists/*
  107. # Add configuration
  108. COPY 10-docker-default.ini /opt/couchdb/etc/default.d/
  109. COPY vm.args /opt/couchdb/etc/
  110. COPY docker-entrypoint.sh /usr/local/bin
  111. RUN ln -s usr/local/bin/docker-entrypoint.sh /docker-entrypoint.sh # backwards compat
  112. #ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
  113. # Setup directories and permissions
  114. RUN chown -R couchdb:couchdb /opt/couchdb/etc/default.d/ /opt/couchdb/etc/vm.args
  115. #VOLUME /opt/couchdb/data
  116. ADD start.sh /start.sh
  117. RUN chmod +x /start.sh
  118. # 5984: Main CouchDB endpoint
  119. # 4369: Erlang portmap daemon (epmd)
  120. # 9100: CouchDB cluster communication port
  121. #EXPOSE 5984 4369 9100
  122. CMD ["/start.sh"]