abdasgupta closed pull request #84: Support multi-arch image building for 
couchdb docker image
URL: https://github.com/apache/couchdb-docker/pull/84
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
index 7db5791..cfb7473 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,5 +11,5 @@ env:
   - RELEASE=dev-cluster
 
 script:
-  - docker build -t couchdb:$RELEASE $RELEASE
-  - docker run -d -p 5984:5984 couchdb:$RELEASE && sleep 10 && curl 
http://localhost:5984
+  - make build VERSION=$RELEASE ARCH=ppc64le 
configure_options="--disable-fauxton --disable-docs"
+  - make build VERSION=$RELEASE configure_options="--disable-fauxton 
--disable-docs" && docker run -d -p 5984:5984 couchdb:$RELEASE && sleep 10 && 
curl http://localhost:5984
diff --git a/1.7.1-couchperuser/Dockerfile.crossbuild 
b/1.7.1-couchperuser/Dockerfile.crossbuild
new file mode 100644
index 0000000..1ed7a4c
--- /dev/null
+++ b/1.7.1-couchperuser/Dockerfile.crossbuild
@@ -0,0 +1,27 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+FROM couchdb:1.7.1
+
+MAINTAINER CouchDB Developers d...@couchdb.apache.org
+
+ENV COUCHPERUSER_SHA 
5d28db3272eea9619d4391b33aae6030f0319ecc54aa2a2f2b6c6a8d448f03f2
+RUN apt-get update && apt-get install -y rebar make \
+ && mkdir -p /usr/local/lib/couchdb/plugins/couchperuser \
+ && cd /usr/local/lib/couchdb/plugins \
+ && curl -L -o couchperuser.tar.gz 
https://github.com/etrepum/couchperuser/archive/1.1.0.tar.gz \
+ && echo "$COUCHPERUSER_SHA *couchperuser.tar.gz" | sha256sum -c - \
+ && tar -xzf couchperuser.tar.gz -C couchperuser --strip-components=1 \
+ && rm couchperuser.tar.gz \
+ && cd couchperuser \
+ && make \
+ && apt-get purge -y --auto-remove rebar make
diff --git a/1.7.1-couchperuser/Makefile b/1.7.1-couchperuser/Makefile
new file mode 100644
index 0000000..122c022
--- /dev/null
+++ b/1.7.1-couchperuser/Makefile
@@ -0,0 +1,56 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+.PHONY: build
+ARCH ?= amd64
+VERSION ?= 1.7.1-couchperuser
+QEMUVERSION=v2.9.1
+TEMP_DIR:=$(shell mktemp -d)
+BUILD_IMAGE ?= couchdb-$(ARCH)
+
+
+ifeq ($(ARCH),amd64)
+       BASEIMAGE?=couchdb:1.7.1
+endif
+
+ifeq ($(ARCH),ppc64le)
+       BASEIMAGE?=couchdb-ppc64le:1.7.1
+        QEMUARCH=ppc64le
+endif
+
+build:
+
+ifeq ($(ARCH),amd64)
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+                | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "/CROSS_BUILD_COPY/d" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       # We just build it using the usual process.
+       docker build -t couchdb:$(VERSION) -f $(TEMP_DIR)/Dockerfile.crossbuild 
$(TEMP_DIR)
+       rm -rf $(TEMP_DIR)
+
+else
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+               | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "s|ARCH|$(QEMUARCH)|g" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       docker run --rm --privileged multiarch/qemu-user-static:register --reset
+       curl -sSL 
https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz
 | tar -xz -C $(TEMP_DIR)
+       # This gosu command is not necessary to run when we are building the 
image. Hence drop it.
+       sed -e "/gosu nobody true; /d" -e "s/CROSS_BUILD_//g" 
$(TEMP_DIR)/Dockerfile.crossbuild > $(TEMP_DIR)/Dockerfile.crossbuild.tmp
+       mv $(TEMP_DIR)/Dockerfile.crossbuild.tmp 
$(TEMP_DIR)/Dockerfile.crossbuild
+       docker build -t $(BUILD_IMAGE):$(VERSION) -f 
$(TEMP_DIR)/Dockerfile.crossbuild $(TEMP_DIR)
+       rm -rf $(TEMP_DIR)
+
+endif
diff --git a/1.7.1/Dockerfile.crossbuild b/1.7.1/Dockerfile.crossbuild
new file mode 100644
index 0000000..9b1c665
--- /dev/null
+++ b/1.7.1/Dockerfile.crossbuild
@@ -0,0 +1,124 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+FROM BASEIMAGE
+MAINTAINER CouchDB Developers d...@couchdb.apache.org
+
+CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
+
+# Install instructions from 
https://cwiki.apache.org/confluence/display/COUCHDB/Debian
+
+RUN groupadd -g 5984 -r couchdb && useradd -u 5984 -d /opt/couchdb -g couchdb 
couchdb
+
+RUN apt-get update -y && apt-get install -y --no-install-recommends \
+    ca-certificates \
+    curl \
+    erlang-nox \
+    libicu52 \
+    libmozjs185-1.0 \
+    libnspr4 \
+    libnspr4-0d \
+  && rm -rf /var/lib/apt/lists/*
+
+ENV GOSU_VERSION 1.10
+ENV TINI_VERSION 0.16.1
+RUN set -ex; \
+    \
+    apt-get update; \
+    apt-get install -y --no-install-recommends wget; \
+    rm -rf /var/lib/apt/lists/*; \
+    \
+    dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
+    \
+# install gosu
+    wget -O /usr/local/bin/gosu 
"https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$dpkgArch";;
 \
+    wget -O /usr/local/bin/gosu.asc 
"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";;
 \
+    export GNUPGHOME="$(mktemp -d)"; \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 
B42F6819007F00F88E364FD4036A9C25BF357DD4; \
+    gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
+    rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
+    chmod +x /usr/local/bin/gosu; \
+    gosu nobody true; \
+    \
+# install tini
+    wget -O /usr/local/bin/tini 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch";;
 \
+    wget -O /usr/local/bin/tini.asc 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch.asc";;
 \
+    export GNUPGHOME="$(mktemp -d)"; \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 
595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7; \
+    gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
+    rm -r "$GNUPGHOME" /usr/local/bin/tini.asc; \
+    chmod +x /usr/local/bin/tini; \
+    tini --version; \
+    \
+    apt-get purge -y --auto-remove wget
+
+# https://www.apache.org/dist/couchdb/KEYS
+ENV GPG_KEYS \
+  15DD4F3B8AACA54740EB78C7B7B7C53943ECCEE1 \
+  1CFBFA43C19B6DF4A0CA3934669C02FFDF3CEBA3 \
+  25BBBAC113C1BFD5AA594A4C9F96B92930380381 \
+  4BFCA2B99BADC6F9F105BEC9C5E32E2D6B065BFB \
+  5D680346FAA3E51B29DBCB681015F68F9DA248BC \
+  7BCCEB868313DDA925DF1805ECA5BCB7BB9656B0 \
+  C3F4DFAEAD621E1C94523AEEC376457E61D50B88 \
+  D2B17F9DA23C0A10991AF2E3D9EE01E47852AEE4 \
+  E0AF0A194D55C84E4A19A801CDB0C0F904F4EE9B
+RUN set -xe \
+  && for key in $GPG_KEYS; do \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
+  done
+
+ENV COUCHDB_VERSION 1.7.1
+
+# download dependencies, compile and install couchdb,
+# set correct permissions, expose couchdb to the outside and disable logging 
to disk
+RUN buildDeps=' \
+    gcc \
+    g++ \
+    erlang-dev \
+    libcurl4-openssl-dev \
+    libicu-dev \
+    libmozjs185-dev \
+    libnspr4-dev \
+    make \
+  ' \
+  && apt-get update && apt-get install -y --no-install-recommends $buildDeps \
+  && curl -fSL 
https://apache.osuosl.org/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz
 -o couchdb.tar.gz \
+  && curl -fSL 
https://www.apache.org/dist/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz.asc
 -o couchdb.tar.gz.asc \
+  && gpg --batch --verify couchdb.tar.gz.asc couchdb.tar.gz \
+  && mkdir -p /usr/src/couchdb \
+  && tar -xzf couchdb.tar.gz -C /usr/src/couchdb --strip-components=1 \
+  && cd /usr/src/couchdb \
+  && ./configure --with-js-lib=/usr/lib --with-js-include=/usr/include/mozjs \
+  && make && make install \
+  && apt-get purge -y --auto-remove $buildDeps \
+  && rm -rf /var/lib/apt/lists/* /usr/src/couchdb /couchdb.tar.gz* \
+  && chown -R couchdb:couchdb \
+    /usr/local/lib/couchdb /usr/local/etc/couchdb \
+    /usr/local/var/lib/couchdb /usr/local/var/log/couchdb 
/usr/local/var/run/couchdb \
+  && chmod -R g+rw \
+    /usr/local/lib/couchdb /usr/local/etc/couchdb \
+    /usr/local/var/lib/couchdb /usr/local/var/log/couchdb 
/usr/local/var/run/couchdb \
+  && mkdir -p /var/lib/couchdb \
+  && sed -e 's/^bind_address = .*$/bind_address = 0.0.0.0/' -i 
/usr/local/etc/couchdb/default.ini \
+  && sed -e 's!/usr/local/var/log/couchdb/couch.log$!/dev/null!' -i 
/usr/local/etc/couchdb/default.ini
+
+COPY ./docker-entrypoint.sh /
+
+# Define mountable directories.
+VOLUME ["/usr/local/var/lib/couchdb"]
+
+EXPOSE 5984
+WORKDIR /var/lib/couchdb
+
+ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
+CMD ["couchdb"]
diff --git a/1.7.1/Makefile b/1.7.1/Makefile
new file mode 100644
index 0000000..6d29f1d
--- /dev/null
+++ b/1.7.1/Makefile
@@ -0,0 +1,56 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+.PHONY: build
+ARCH ?= amd64
+VERSION ?= 1.7.1
+QEMUVERSION=v2.9.1
+TEMP_DIR:=$(shell mktemp -d)
+BUILD_IMAGE ?= couchdb-$(ARCH)
+
+
+ifeq ($(ARCH),amd64)
+       BASEIMAGE?=debian:jessie
+endif
+
+ifeq ($(ARCH),ppc64le)
+       BASEIMAGE?=ppc64le/debian:jessie
+        QEMUARCH=ppc64le
+endif
+
+build:
+
+ifeq ($(ARCH),amd64)
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+                | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "/CROSS_BUILD_COPY/d" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       # We just build it using the usual process.
+       docker build -t couchdb:$(VERSION) -f $(TEMP_DIR)/Dockerfile.crossbuild 
$(TEMP_DIR)
+       rm -rf $(TEMP_DIR)
+
+else
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+               | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "s|ARCH|$(QEMUARCH)|g" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       docker run --rm --privileged multiarch/qemu-user-static:register --reset
+       curl -sSL 
https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz
 | tar -xz -C $(TEMP_DIR)
+       # This gosu command is not necessary to run when we are building the 
image. Hence drop it.
+       sed -e "/gosu nobody true; /d" -e "s/CROSS_BUILD_//g" 
$(TEMP_DIR)/Dockerfile.crossbuild > $(TEMP_DIR)/Dockerfile.crossbuild.tmp
+       mv $(TEMP_DIR)/Dockerfile.crossbuild.tmp 
$(TEMP_DIR)/Dockerfile.crossbuild
+       docker build -t $(BUILD_IMAGE):$(VERSION) -f 
$(TEMP_DIR)/Dockerfile.crossbuild $(TEMP_DIR)
+       rm -rf $(TEMP_DIR)
+
+endif
diff --git a/2.1.1/Dockerfile.crossbuild b/2.1.1/Dockerfile.crossbuild
new file mode 100644
index 0000000..fe1f2a4
--- /dev/null
+++ b/2.1.1/Dockerfile.crossbuild
@@ -0,0 +1,126 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+FROM BASEIMAGE
+MAINTAINER CouchDB Developers d...@couchdb.apache.org
+
+CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
+# Add CouchDB user account
+RUN groupadd -g 5984 -r couchdb && useradd -u 5984 -d /opt/couchdb -g couchdb 
couchdb
+
+RUN apt-get update -y && apt-get install -y --no-install-recommends \
+    ca-certificates \
+    curl \
+    erlang-nox \
+    libicu52 \
+    erlang-reltool \
+    libmozjs185-1.0 \
+    openssl \
+  && rm -rf /var/lib/apt/lists/*
+
+# grab gosu for easy step-down from root and tini for signal handling
+# see https://github.com/apache/couchdb-docker/pull/28#discussion_r141112407
+ENV GOSU_VERSION 1.10
+ENV TINI_VERSION 0.16.1
+RUN set -ex; \
+       apt-get update; \
+       apt-get install -y --no-install-recommends wget; \
+       rm -rf /var/lib/apt/lists/*; \
+       dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
+       \
+# install gosu
+       wget -O /usr/local/bin/gosu 
"https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$dpkgArch";;
 \
+       wget -O /usr/local/bin/gosu.asc 
"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";;
 \
+       export GNUPGHOME="$(mktemp -d)"; \
+       gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 
B42F6819007F00F88E364FD4036A9C25BF357DD4; \
+       gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
+       rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
+       chmod +x /usr/local/bin/gosu; \
+        gosu nobody true; \
+        \
+# install tini
+
+       wget -O /usr/local/bin/tini 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch";;
 \
+       wget -O /usr/local/bin/tini.asc 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch.asc";;
 \
+       export GNUPGHOME="$(mktemp -d)"; \
+       gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 
595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7; \
+       gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
+       rm -r "$GNUPGHOME" /usr/local/bin/tini.asc; \
+       chmod +x /usr/local/bin/tini; \
+       tini --version; \
+       \
+       apt-get purge -y --auto-remove wget
+
+# https://www.apache.org/dist/couchdb/KEYS
+ENV GPG_KEYS \
+  15DD4F3B8AACA54740EB78C7B7B7C53943ECCEE1 \
+  1CFBFA43C19B6DF4A0CA3934669C02FFDF3CEBA3 \
+  25BBBAC113C1BFD5AA594A4C9F96B92930380381 \
+  4BFCA2B99BADC6F9F105BEC9C5E32E2D6B065BFB \
+  5D680346FAA3E51B29DBCB681015F68F9DA248BC \
+  7BCCEB868313DDA925DF1805ECA5BCB7BB9656B0 \
+  C3F4DFAEAD621E1C94523AEEC376457E61D50B88 \
+  D2B17F9DA23C0A10991AF2E3D9EE01E47852AEE4 \
+  E0AF0A194D55C84E4A19A801CDB0C0F904F4EE9B \
+  29E4F38113DF707D722A6EF91FE9AF73118F1A7C \
+  2EC788AE3F239FA13E82D215CDE711289384AE37
+RUN set -xe \
+  && for key in $GPG_KEYS; do \
+    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
+  done
+
+ENV COUCHDB_VERSION 2.1.1
+
+# Download dev dependencies
+RUN buildDeps=' \
+    apt-transport-https \
+    gcc \
+    g++ \
+    erlang-dev \
+    libcurl4-openssl-dev \
+    libicu-dev \
+    libmozjs185-dev \
+    make \
+  ' \
+ && apt-get update -y -qq && apt-get install -y --no-install-recommends 
$buildDeps \
+ # Acquire CouchDB source code
+ && cd /usr/src && mkdir couchdb \
+ && curl -fSL 
https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz
 -o couchdb.tar.gz \
+ && curl -fSL 
https://dist.apache.org/repos/dist/release/couchdb/source/$COUCHDB_VERSION/apache-couchdb-$COUCHDB_VERSION.tar.gz.asc
 -o couchdb.tar.gz.asc \
+ && gpg --batch --verify couchdb.tar.gz.asc couchdb.tar.gz \
+ && tar -xzf couchdb.tar.gz -C couchdb --strip-components=1 \
+ && cd couchdb \
+ # Build the release and install into /opt
+ && ./configure --disable-docs \
+ && make release \
+ && mv /usr/src/couchdb/rel/couchdb /opt/ \
+ # Cleanup build detritus
+ && apt-get purge -y --auto-remove $buildDeps \
+ && rm -rf /var/lib/apt/lists/* /usr/src/couchdb* \
+ && mkdir /opt/couchdb/data \
+ && chown -R couchdb:couchdb /opt/couchdb
+
+# Add configuration
+COPY 10-docker-default.ini /opt/couchdb/etc/default.d/
+COPY vm.args /opt/couchdb/etc/
+
+COPY ./docker-entrypoint.sh /
+
+# Setup directories and permissions
+RUN chown -R couchdb:couchdb /opt/couchdb/etc/local.d/ /opt/couchdb/etc/vm.args
+
+WORKDIR /opt/couchdb
+EXPOSE 5984 4369 9100
+VOLUME ["/opt/couchdb/data"]
+
+ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
+CMD ["/opt/couchdb/bin/couchdb"]
diff --git a/2.1.1/Makefile b/2.1.1/Makefile
new file mode 100644
index 0000000..211add6
--- /dev/null
+++ b/2.1.1/Makefile
@@ -0,0 +1,55 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+.PHONY: build
+ARCH ?= amd64
+QEMUVERSION=v2.9.1
+TEMP_DIR:=$(shell mktemp -d)
+BUILD_IMAGE ?= couchdb-$(ARCH)
+
+
+ifeq ($(ARCH),amd64)
+       BASEIMAGE?=debian:jessie
+endif
+
+ifeq ($(ARCH),ppc64le)
+       BASEIMAGE?=ppc64le/debian:jessie
+        QEMUARCH=ppc64le
+endif
+
+build:
+
+ifeq ($(ARCH),amd64)
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+                | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "/CROSS_BUILD_COPY/d" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       # We just build it using the usual process.
+       docker build -t couchdb:2.1.1 -f $(TEMP_DIR)/Dockerfile.crossbuild 
$(TEMP_DIR)
+       rm -rf $(TEMP_DIR)
+
+else
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+               | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "s|ARCH|$(QEMUARCH)|g" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       docker run --rm --privileged multiarch/qemu-user-static:register --reset
+       curl -sSL 
https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz
 | tar -xz -C $(TEMP_DIR)
+       # This gosu command is not necessary to run when we are building the 
image. Hence drop it.
+       sed -e "/gosu nobody true; /d" -e "s/CROSS_BUILD_//g" 
$(TEMP_DIR)/Dockerfile.crossbuild > $(TEMP_DIR)/Dockerfile.crossbuild.tmp
+       mv $(TEMP_DIR)/Dockerfile.crossbuild.tmp 
$(TEMP_DIR)/Dockerfile.crossbuild
+       docker build -t $(BUILD_IMAGE):2.1.1 -f 
$(TEMP_DIR)/Dockerfile.crossbuild $(TEMP_DIR)
+       rm -rf $(TEMP_DIR)
+
+endif
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b693933
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+.PHONY: build
+VERSION ?= 2.1.1
+
+build:
+       cd $(VERSION); make build
diff --git a/dev-cluster/Dockerfile b/dev-cluster/Dockerfile
index c89c104..ef3a4ce 100644
--- a/dev-cluster/Dockerfile
+++ b/dev-cluster/Dockerfile
@@ -12,7 +12,7 @@
 
 # Base layer containing dependencies needed at runtime. This layer will be
 # cached after the initial build.
-FROM debian:stretch
+FROM ubuntu:16.04
 
 MAINTAINER CouchDB Developers d...@couchdb.apache.org
 
@@ -25,7 +25,7 @@ RUN apt-get update -y && apt-get install -y 
--no-install-recommends \
     dirmngr \
     gnupg \
     haproxy \ 
-    libicu57 \
+    libicu55 \
     libmozjs185-1.0 \
     openssl \
     python && \
@@ -92,10 +92,7 @@ RUN pip install \
 
 # Node is special
 RUN set -ex; \
-    curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add 
-; \
-    echo 'deb https://deb.nodesource.com/node_6.x stretch main' > 
/etc/apt/sources.list.d/nodesource.list; \
-    echo 'deb-src https://deb.nodesource.com/node_6.x stretch main' >> 
/etc/apt/sources.list.d/nodesource.list; \
-    apt-get update -y && apt-get install -y nodejs; \
+    apt-get update -y && apt-get install -y nodejs npm; \
     npm install -g grunt-cli
 
 
diff --git a/dev-cluster/Dockerfile.crossbuild 
b/dev-cluster/Dockerfile.crossbuild
new file mode 100644
index 0000000..b516145
--- /dev/null
+++ b/dev-cluster/Dockerfile.crossbuild
@@ -0,0 +1,123 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+# Base layer containing dependencies needed at runtime. This layer will be
+# cached after the initial build.
+FROM BASEIMAGE
+MAINTAINER CouchDB Developers d...@couchdb.apache.org
+
+CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
+
+# Add CouchDB user account
+RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb
+
+RUN apt-get update -y && apt-get install -y --no-install-recommends \
+    ca-certificates \
+    curl \
+    dirmngr \
+    gnupg \
+    haproxy \ 
+    libicu55 \
+    libmozjs185-1.0 \
+    openssl \
+    python && \
+  rm -rf /var/lib/apt/lists/*
+
+# grab gosu for easy step-down from root and tini for signal handling
+# see https://github.com/apache/couchdb-docker/pull/28#discussion_r141112407
+ENV GOSU_VERSION 1.10
+ENV TINI_VERSION 0.16.1
+RUN set -ex; \
+  apt-get update; \
+  apt-get install -y --no-install-recommends wget; \
+  rm -rf /var/lib/apt/lists/*; \
+  dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
+# install gosu
+  wget -O /usr/local/bin/gosu 
"https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$dpkgArch";;
 \
+  wget -O /usr/local/bin/gosu.asc 
"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";;
 \
+  export GNUPGHOME="$(mktemp -d)"; \
+  for server in $(shuf -e ha.pool.sks-keyservers.net \
+                          hkp://p80.pool.sks-keyservers.net:80 \
+                          keyserver.ubuntu.com \
+                          hkp://keyserver.ubuntu.com:80 \
+                          pgp.mit.edu) ; do \
+    gpg --keyserver "$server" --recv-keys 
B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \
+  done; \
+  gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
+  rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
+  chmod +x /usr/local/bin/gosu; \
+  gosu nobody true; \
+# install tini
+  wget -O /usr/local/bin/tini 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch";;
 \
+  wget -O /usr/local/bin/tini.asc 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch.asc";;
 \
+  export GNUPGHOME="$(mktemp -d)"; \
+  for server in $(shuf -e ha.pool.sks-keyservers.net \
+                          hkp://p80.pool.sks-keyservers.net:80 \
+                          keyserver.ubuntu.com \
+                          hkp://keyserver.ubuntu.com:80 \
+                          pgp.mit.edu) ; do \
+    gpg --keyserver "$server" --recv-keys 
595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
+  done; \
+  gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
+  rm -rf "$GNUPGHOME" /usr/local/bin/tini.asc; \
+  chmod +x /usr/local/bin/tini; \
+  tini --version; \
+  apt-get purge -y --auto-remove wget
+
+RUN apt-get update -y && apt-get install -y --no-install-recommends \
+    apt-transport-https \
+    build-essential \
+    erlang-nox \
+    erlang-reltool \
+    erlang-dev \
+    git \
+    libcurl4-openssl-dev \
+    libicu-dev \
+    libmozjs185-dev \
+    python-setuptools \ 
+    python-pip \
+    python-wheel
+
+RUN pip install \
+    sphinx \
+    sphinx_rtd_theme
+
+# Node is special
+RUN set -ex; \
+    apt-get update -y && apt-get install -y nodejs npm; \
+    npm install -g grunt-cli
+
+
+# Clone CouchDB source code including all dependencies
+ARG clone_url=https://gitbox.apache.org/repos/asf/couchdb.git
+RUN git clone $clone_url /usr/src/couchdb
+WORKDIR /usr/src/couchdb
+RUN ./configure
+
+ARG checkout_branch=master
+ARG configure_options
+
+WORKDIR /usr/src/couchdb/
+RUN git fetch origin \
+    && git checkout $checkout_branch \
+    && ./configure $configure_options \
+    && make all
+
+# Setup directories and permissions
+RUN chown -R couchdb:couchdb /usr/src/couchdb
+
+WORKDIR /opt/couchdb
+EXPOSE 5984 15984 25984 35984
+VOLUME ["/usr/src/couchdb/dev/lib"]
+
+ENTRYPOINT ["tini", "--", "/usr/src/couchdb/dev/run"]
+CMD ["--with-haproxy"]
diff --git a/dev-cluster/Makefile b/dev-cluster/Makefile
new file mode 100644
index 0000000..5a8d456
--- /dev/null
+++ b/dev-cluster/Makefile
@@ -0,0 +1,57 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+.PHONY: build
+ARCH ?= amd64
+configure_options ?= "--disable-fauxton --disable-docs"
+VERSION ?= dev-cluster
+QEMUVERSION=v2.9.1
+TEMP_DIR:=$(shell mktemp -d)
+BUILD_IMAGE ?= couchdb-$(ARCH)
+
+
+ifeq ($(ARCH),amd64)
+       BASEIMAGE?=ubuntu:16.04
+endif
+
+ifeq ($(ARCH),ppc64le)
+       BASEIMAGE?=ppc64le/ubuntu:16.04
+        QEMUARCH=ppc64le
+endif
+
+build:
+
+ifeq ($(ARCH),amd64)
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+                | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "/CROSS_BUILD_COPY/d" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       # We just build it using the usual process.
+       docker build -t couchdb:$(VERSION) -f $(TEMP_DIR)/Dockerfile.crossbuild 
$(TEMP_DIR) --build-arg configure_options="$(configure_options)"
+       rm -rf $(TEMP_DIR)
+
+else
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+               | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "s|ARCH|$(QEMUARCH)|g" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       docker run --rm --privileged multiarch/qemu-user-static:register --reset
+       curl -sSL 
https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz
 | tar -xz -C $(TEMP_DIR)
+       # This gosu command is not necessary to run when we are building the 
image. Hence drop it.
+       sed -e "/gosu nobody true; /d" -e "s/CROSS_BUILD_//g" 
$(TEMP_DIR)/Dockerfile.crossbuild > $(TEMP_DIR)/Dockerfile.crossbuild.tmp
+       mv $(TEMP_DIR)/Dockerfile.crossbuild.tmp 
$(TEMP_DIR)/Dockerfile.crossbuild
+       docker build -t $(BUILD_IMAGE):$(VERSION) -f 
$(TEMP_DIR)/Dockerfile.crossbuild $(TEMP_DIR) --build-arg 
configure_options="$(configure_options)"
+       rm -rf $(TEMP_DIR)
+
+endif
diff --git a/dev/Dockerfile b/dev/Dockerfile
index 1b43ba7..ef2ec0a 100644
--- a/dev/Dockerfile
+++ b/dev/Dockerfile
@@ -12,7 +12,7 @@
 
 # Base layer containing dependencies needed at runtime. This layer will be
 # cached after the initial build.
-FROM debian:stretch as runtime
+FROM ubuntu:16.04 as runtime
 
 MAINTAINER CouchDB Developers d...@couchdb.apache.org
 
@@ -24,7 +24,7 @@ RUN apt-get update -y && apt-get install -y 
--no-install-recommends \
     curl \
     dirmngr \
     gnupg \
-    libicu57 \
+    libicu55 \
     libmozjs185-1.0 \
     openssl \
     python && \
@@ -94,10 +94,7 @@ RUN pip install \
 
 # Node is special
 RUN set -ex; \
-    curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add 
-; \
-    echo 'deb https://deb.nodesource.com/node_6.x stretch main' > 
/etc/apt/sources.list.d/nodesource.list; \
-    echo 'deb-src https://deb.nodesource.com/node_6.x stretch main' >> 
/etc/apt/sources.list.d/nodesource.list; \
-    apt-get update -y && apt-get install -y nodejs; \
+    apt-get update -y && apt-get install -y nodejs npm; \
     npm install -g grunt-cli
 
 
diff --git a/dev/Dockerfile.crossbuild b/dev/Dockerfile.crossbuild
new file mode 100644
index 0000000..dc2f577
--- /dev/null
+++ b/dev/Dockerfile.crossbuild
@@ -0,0 +1,141 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+# Base layer containing dependencies needed at runtime. This layer will be
+# cached after the initial build.
+FROM BASEIMAGE as runtime
+
+MAINTAINER CouchDB Developers d...@couchdb.apache.org
+
+CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
+
+# Add CouchDB user account
+RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb
+
+RUN apt-get update -y && apt-get install -y --no-install-recommends \
+    ca-certificates \
+    curl \
+    dirmngr \
+    gnupg \
+    libicu55 \
+    libmozjs185-1.0 \
+    openssl \
+    python && \
+  rm -rf /var/lib/apt/lists/*
+
+# grab gosu for easy step-down from root and tini for signal handling
+# see https://github.com/apache/couchdb-docker/pull/28#discussion_r141112407
+ENV GOSU_VERSION 1.10
+ENV TINI_VERSION 0.16.1
+RUN set -ex; \
+  apt-get update; \
+  apt-get install -y --no-install-recommends wget; \
+  rm -rf /var/lib/apt/lists/*; \
+  dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
+# install gosu
+  wget -O /usr/local/bin/gosu 
"https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-$dpkgArch";;
 \
+  wget -O /usr/local/bin/gosu.asc 
"https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";;
 \
+  export GNUPGHOME="$(mktemp -d)"; \
+  for server in $(shuf -e ha.pool.sks-keyservers.net \
+                          hkp://p80.pool.sks-keyservers.net:80 \
+                          keyserver.ubuntu.com \
+                          hkp://keyserver.ubuntu.com:80 \
+                          pgp.mit.edu) ; do \
+    gpg --keyserver "$server" --recv-keys 
B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || : ; \
+  done; \
+  gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
+  rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
+  chmod +x /usr/local/bin/gosu; \
+  gosu nobody true; \
+# install tini
+  wget -O /usr/local/bin/tini 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch";;
 \
+  wget -O /usr/local/bin/tini.asc 
"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-$dpkgArch.asc";;
 \
+  export GNUPGHOME="$(mktemp -d)"; \
+  for server in $(shuf -e ha.pool.sks-keyservers.net \
+                          hkp://p80.pool.sks-keyservers.net:80 \
+                          keyserver.ubuntu.com \
+                          hkp://keyserver.ubuntu.com:80 \
+                          pgp.mit.edu) ; do \
+    gpg --keyserver "$server" --recv-keys 
595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 && break || : ; \
+  done; \
+  gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini; \
+  rm -rf "$GNUPGHOME" /usr/local/bin/tini.asc; \
+  chmod +x /usr/local/bin/tini; \
+  tini --version; \
+  apt-get purge -y --auto-remove wget
+
+# Dependencies only needed during build time. This layer will also be cached
+FROM runtime AS build_dependencies
+
+RUN apt-get update -y && apt-get install -y --no-install-recommends \
+    apt-transport-https \
+    build-essential \
+    erlang-nox \
+    erlang-reltool \
+    erlang-dev \
+    git \
+    libcurl4-openssl-dev \
+    libicu-dev \
+    libmozjs185-dev \
+    python-setuptools \ 
+    python-pip \
+    python-wheel
+
+RUN pip install \
+    sphinx \
+    sphinx_rtd_theme
+
+# Node is special
+RUN set -ex; \
+    apt-get update -y && apt-get install -y nodejs npm; \
+    npm install -g grunt-cli
+
+
+# Clone CouchDB source code including all dependencies
+ARG clone_url=https://gitbox.apache.org/repos/asf/couchdb.git
+RUN git clone $clone_url /usr/src/couchdb
+WORKDIR /usr/src/couchdb
+RUN ./configure
+
+# This layer performs the actual build of a relocatable, self-contained
+# release of CouchDB. It pulls down the latest changes from the remote
+# origin (because the layer above will be cached) and switches to the
+# branch specified in the build_arg (defaults to master)
+FROM build_dependencies AS build
+
+ARG checkout_branch=master
+ARG configure_options
+
+WORKDIR /usr/src/couchdb/
+RUN git fetch origin \
+    && git checkout $checkout_branch \
+    && ./configure $configure_options \
+    && make release
+
+# This results in a single layer image (or at least skips the build stuff?)
+FROM runtime
+COPY --from=build /usr/src/couchdb/rel/couchdb /opt/couchdb
+
+# Add configuration
+COPY local.ini /opt/couchdb/etc/default.d/
+COPY vm.args /opt/couchdb/etc/
+COPY docker-entrypoint.sh /
+
+# Setup directories and permissions
+RUN chown -R couchdb:couchdb /opt/couchdb/etc/default.d/ 
/opt/couchdb/etc/vm.args
+
+WORKDIR /opt/couchdb
+EXPOSE 5984 4369 9100
+VOLUME ["/opt/couchdb/data"]
+
+ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
+CMD ["/opt/couchdb/bin/couchdb"]
diff --git a/dev/Makefile b/dev/Makefile
new file mode 100644
index 0000000..e022ed6
--- /dev/null
+++ b/dev/Makefile
@@ -0,0 +1,57 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+.PHONY: build
+ARCH ?= amd64
+configure_options ?= "--disable-fauxton --disable-docs"
+VERSION ?= dev
+QEMUVERSION=v2.9.1
+TEMP_DIR:=$(shell mktemp -d)
+BUILD_IMAGE ?= couchdb-$(ARCH)
+
+
+ifeq ($(ARCH),amd64)
+       BASEIMAGE?=ubuntu:16.04
+endif
+
+ifeq ($(ARCH),ppc64le)
+       BASEIMAGE?=ppc64le/ubuntu:16.04
+        QEMUARCH=ppc64le
+endif
+
+build:
+
+ifeq ($(ARCH),amd64)
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+                | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "/CROSS_BUILD_COPY/d" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       # We just build it using the usual process.
+       docker build -t couchdb:$(VERSION) -f $(TEMP_DIR)/Dockerfile.crossbuild 
$(TEMP_DIR) --build-arg configure_options="$(configure_options)"
+       rm -rf $(TEMP_DIR)
+
+else
+       cp ./* $(TEMP_DIR)
+       cat Dockerfile.crossbuild \
+               | sed "s|BASEIMAGE|$(BASEIMAGE)|g" \
+                | sed "s|ARCH|$(QEMUARCH)|g" \
+                > $(TEMP_DIR)/Dockerfile.crossbuild
+       docker run --rm --privileged multiarch/qemu-user-static:register --reset
+       curl -sSL 
https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz
 | tar -xz -C $(TEMP_DIR)
+       # This gosu command is not necessary to run when we are building the 
image. Hence drop it.
+       sed -e "/gosu nobody true; /d" -e "s/CROSS_BUILD_//g" 
$(TEMP_DIR)/Dockerfile.crossbuild > $(TEMP_DIR)/Dockerfile.crossbuild.tmp
+       mv $(TEMP_DIR)/Dockerfile.crossbuild.tmp 
$(TEMP_DIR)/Dockerfile.crossbuild
+       docker build -t $(BUILD_IMAGE):$(VERSION) -f 
$(TEMP_DIR)/Dockerfile.crossbuild $(TEMP_DIR) --build-arg 
configure_options="$(configure_options)"
+       rm -rf $(TEMP_DIR)
+
+endif


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to