wohali closed pull request #60: Support multi-arch image building for couchdb docker image URL: https://github.com/apache/couchdb-docker/pull/60
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 8ac681d..d347ea7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,10 @@ services: - docker before_install: - - docker build -t couchdb:1.7.1 1.7.1 - - docker build -t couchdb:1.7.1-couchperuser 1.7.1-couchperuser - - docker build -t couchdb:2.1.1 2.1.1 + - make build VERSION=1.7.1 + - make build VERSION=1.7.1-couchperuser + - make build + - make build ARCH=ppc64le script: - docker run -d -p 5984:5984 couchdb:1.7.1 && sleep 5 && curl http://localhost:5984 diff --git a/2.1.1/Dockerfile b/2.1.1/Dockerfile.crossbuild similarity index 97% rename from 2.1.1/Dockerfile rename to 2.1.1/Dockerfile.crossbuild index 9f5f92f..b8e525f 100644 --- a/2.1.1/Dockerfile +++ b/2.1.1/Dockerfile.crossbuild @@ -10,10 +10,10 @@ # License for the specific language governing permissions and limitations under # the License. -FROM debian:jessie - +FROM BASEIMAGE MAINTAINER CouchDB Developers [email protected] +CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/ # Add CouchDB user account RUN groupadd -r couchdb && useradd -d /opt/couchdb -g couchdb couchdb @@ -21,8 +21,8 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ erlang-nox \ - erlang-reltool \ libicu52 \ + erlang-reltool \ libmozjs185-1.0 \ openssl \ && rm -rf /var/lib/apt/lists/* @@ -32,11 +32,9 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \ 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 @@ -47,9 +45,10 @@ RUN set -ex; \ 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; \ - \ + 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)"; \ diff --git a/2.1.1/Makefile b/2.1.1/Makefile new file mode 100644 index 0000000..10aac4b --- /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..a95ca88 --- /dev/null +++ b/Makefile @@ -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. + +.PHONY: build +VERSION ?= 2.1.1 + +build: +ifeq ($(VERSION), 2.1.1) + cd $(VERSION); make build +endif + +ifeq ($(VERSION), 1.7.1) + docker build -t couchdb:1.7.1 1.7.1 +endif + +ifeq ($(VERSION), 1.7.1-couchperuser) + docker build -t couchdb:1.7.1-couchperuser 1.7.1-couchperuser +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: [email protected] With regards, Apache Git Services
