Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to simplify creation of multiarch images #157

Merged
merged 2 commits into from
Dec 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions build-manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

# This shell script builds all the supported architectures for
# a single version, pushes them to Docker Hub, then creates the
# manifest.

# Usage: ./build-manifest.sh <VERSION>

# With help from https://lobradov.github.io/Building-docker-multiarch-images/

set -e

for arch in amd64 arm64v8 ppc64le; do
./build.sh $1 ${arch}
docker push apache/couchdb:${arch}-$1
done

docker manifest create apache/couchdb:$1 \
apache/couchdb:amd64-$1 \
apache/couchdb:arm64v8-$1 \
apache/couchdb:ppc64le-$1

docker manifest annotate apache/couchdb:$1 \
apache/couchdb:arm64v8-$1 --os linux --arch arm64 --variant armv8

docker manifest annotate apache/couchdb:$1 \
apache/couchdb:ppc64le-$1 --os linux --arch ppc64le

docker manifest push apache/couchdb:$1
wohali marked this conversation as resolved.
Show resolved Hide resolved

docker manifest inspect apache/couchdb:$1
38 changes: 38 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

# This shell script makes it easier to build multi-platform
# architecture Docker containers on an x86_64 host.

# Usage: ./build.sh <VERSION> <ARCH>

# Inspired by https://github.com/jessfraz/irssi/blob/master/.travis.yml

set -e

TARGET=$1
ARCH=${2:-amd64}

if [ -n "${ARCH:-}" ]; then
from="$(awk '$1 == toupper("FROM") { print $2 }' $TARGET/Dockerfile)"
docker pull "$ARCH/$from"
docker tag "$ARCH/$from" "$from"
fi

docker build -t apache/couchdb:$ARCH-$TARGET $TARGET