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

Move ci to buildx for multiarch images #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
91 changes: 37 additions & 54 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ stages:

before_script:
- echo $DOCKER_PASSWORD > /tmp/docker.pass
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) edge"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- mkdir -vp ~/.docker/cli-plugins/
- curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
- chmod a+x ~/.docker/cli-plugins/docker-buildx

jobs:
include:
Expand All @@ -48,103 +54,80 @@ jobs:
# These take longer to build and are put in their own jobs
###############################################################################

- name: Build Docker image for build-from-source flavors -- alpine / aarch64
stage: build
arch: arm64
script:
- ./docker_build_and_push_flavor.sh alpine-aarch64 alpine/Dockerfile

- name: Build Docker image for build-from-source flavors -- alpine / amd64
- name: Build Docker image for build-from-source flavors -- alpine
stage: build
arch: amd64
script:
- ./docker_build_and_push_flavor.sh alpine-amd64 alpine/Dockerfile
- ./docker_build_and_push_flavor.sh alpine linux/arm/v7,linux/arm64/v8,linux/amd64 alpine/Dockerfile

- name: Build Docker image for build-from-source flavor -- bionic / aarch64
arch: arm64
stage: build
script:
- ./docker_build_and_push_flavor.sh bionic-aarch64 bionic/Dockerfile

- name: Build Docker image for build-from-source flavor -- bionic / amd64
- name: Build Docker image for build-from-source flavor -- bionic
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh bionic-amd64 bionic/Dockerfile
- ./docker_build_and_push_flavor.sh bionic linux/arm/v7,linux/arm64/v8,linux/amd64 bionic/Dockerfile

- name: Build Docker image for build-from-source flavor -- bionic / s390x
arch: s390x
stage: build
script:
- ./docker_build_and_push_flavor.sh bionic-s390x bionic/Dockerfile --build-arg RESTY_PCRE_BUILD_OPTIONS="" --build-arg RESTY_PCRE_OPTIONS=""

- name: Build Docker image for build-from-source flavor -- focal / aarch64
arch: arm64
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh focal-aarch64 focal/Dockerfile
- ./docker_build_and_push_flavor.sh bionic s390x bionic/Dockerfile --build-arg RESTY_PCRE_BUILD_OPTIONS="" --build-arg RESTY_PCRE_OPTIONS=""

- name: Build Docker image for build-from-source flavor -- focal / amd64
- name: Build Docker image for build-from-source flavor -- focal
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh focal-amd64 focal/Dockerfile
- ./docker_build_and_push_flavor.sh focal linux/arm/v7,linux/arm64/v8,linux/amd64 focal/Dockerfile

- name: Build Docker image for build-from-source flavor -- focal / s390x
arch: s390x
stage: build
script:
- ./docker_build_and_push_flavor.sh focal-s390x focal/Dockerfile --build-arg RESTY_PCRE_BUILD_OPTIONS="" --build-arg RESTY_PCRE_OPTIONS=""

- name: Build Docker image for build-from-source flavor -- jammy / aarch64
arch: arm64
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh jammy-aarch64 jammy/Dockerfile
- ./docker_build_and_push_flavor.sh focal s390x focal/Dockerfile --build-arg RESTY_PCRE_BUILD_OPTIONS="" --build-arg RESTY_PCRE_OPTIONS=""

- name: Build Docker image for build-from-source flavor -- jammy / amd64
- name: Build Docker image for build-from-source flavor -- jammy
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh jammy-amd64 jammy/Dockerfile
- ./docker_build_and_push_flavor.sh jammy linux/arm/v7,linux/arm64/v8,linux/amd64 jammy/Dockerfile


# jammy / s390x disabled due to build issues (#209)
# - name: Build Docker image for build-from-source flavor -- jammy / s390x
# arch: s390x
# stage: build
# script:
# - ./docker_build_and_push_flavor.sh jammy-s390x jammy/Dockerfile --build-arg RESTY_PCRE_BUILD_OPTIONS="" --build-arg RESTY_PCRE_OPTIONS=""
# - ./docker_build_and_push_flavor.sh jammy s390x jammy/Dockerfile --build-arg RESTY_PCRE_BUILD_OPTIONS="" --build-arg RESTY_PCRE_OPTIONS=""

###############################################################################
# Build From OpenResty Upstream Flavors
# These are shorter to build are put in the same job (per architecture)
###############################################################################

- name: Build Docker image for upstream flavors -- aarch64
arch: arm64
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh alpine-apk-aarch64 alpine-apk/Dockerfile
- ./docker_build_and_push_flavor.sh amzn2-aarch64 centos/Dockerfile --build-arg RESTY_IMAGE_BASE=amazonlinux --build-arg RESTY_IMAGE_TAG=2 --build-arg RESTY_YUM_REPO="https://openresty.org/package/amazon/openresty.repo" --build-arg RESTY_RPM_DIST="amzn2" --build-arg RESTY_RPM_ARCH="aarch64"
- ./docker_build_and_push_flavor.sh rocky-aarch64 fedora/Dockerfile --build-arg RESTY_IMAGE_BASE=rockylinux --build-arg RESTY_IMAGE_TAG=8.5 --build-arg RESTY_YUM_REPO="https://openresty.org/package/rocky/openresty.repo" --build-arg RESTY_RPM_DIST="el8" --build-arg RESTY_RPM_ARCH="aarch64"
- ./docker_build_and_push_flavor.sh centos-aarch64 centos/Dockerfile --build-arg RESTY_RPM_ARCH=aarch64
- ./docker_build_and_push_flavor.sh centos7-aarch64 centos7/Dockerfile --build-arg RESTY_RPM_ARCH=aarch64
# - ./docker_build_and_push_flavor.sh fedora-aarch64 fedora/Dockerfile --build-arg RESTY_RPM_ARCH=aarch64
- ./docker_build_and_push_flavor.sh bullseye-aarch64 bullseye/Dockerfile --build-arg RESTY_APT_REPO="https://openresty.org/package/arm64/debian"
- ./docker_build_and_push_flavor.sh buster-aarch64 buster/Dockerfile --build-arg RESTY_APT_REPO="https://openresty.org/package/arm64/debian"
- ./docker_build_and_push_flavor.sh alpine-apk linux/arm64/v8 alpine-apk/Dockerfile
- ./docker_build_and_push_flavor.sh amzn2 linux/arm64/v8 centos/Dockerfile --build-arg RESTY_IMAGE_BASE=amazonlinux --build-arg RESTY_IMAGE_TAG=2 --build-arg RESTY_YUM_REPO="https://openresty.org/package/amazon/openresty.repo" --build-arg RESTY_RPM_DIST="amzn2" --build-arg RESTY_RPM_ARCH="aarch64"
- ./docker_build_and_push_flavor.sh rocky linux/arm64/v8 fedora/Dockerfile --build-arg RESTY_IMAGE_BASE=rockylinux --build-arg RESTY_IMAGE_TAG=8.5 --build-arg RESTY_YUM_REPO="https://openresty.org/package/rocky/openresty.repo" --build-arg RESTY_RPM_DIST="el8" --build-arg RESTY_RPM_ARCH="aarch64"
- ./docker_build_and_push_flavor.sh centos linux/arm64/v8 centos/Dockerfile --build-arg RESTY_RPM_ARCH=aarch64
- ./docker_build_and_push_flavor.sh centos7 linux/arm64/v8 centos7/Dockerfile --build-arg RESTY_RPM_ARCH=aarch64
# - ./docker_build_and_push_flavor.sh fedora linux/arm64/v8 fedora/Dockerfile --build-arg RESTY_RPM_ARCH=aarch64
- ./docker_build_and_push_flavor.sh bullseye linux/arm64/v8 bullseye/Dockerfile --build-arg RESTY_APT_REPO="https://openresty.org/package/arm64/debian"
- ./docker_build_and_push_flavor.sh buster linux/arm64/v8 buster/Dockerfile --build-arg RESTY_APT_REPO="https://openresty.org/package/arm64/debian"

- name: Build Docker image for upstream flavors -- amd64
arch: amd64
stage: build
script:
- ./docker_build_and_push_flavor.sh alpine-apk-amd64 alpine-apk/Dockerfile
- ./docker_build_and_push_flavor.sh amzn2-amd64 centos/Dockerfile --build-arg RESTY_IMAGE_BASE=amazonlinux --build-arg RESTY_IMAGE_TAG=2 --build-arg RESTY_YUM_REPO="https://openresty.org/package/amazon/openresty.repo" --build-arg RESTY_RPM_DIST="amzn2"
- ./docker_build_and_push_flavor.sh rocky-amd64 fedora/Dockerfile --build-arg RESTY_IMAGE_BASE=rockylinux --build-arg RESTY_IMAGE_TAG=8.5 --build-arg RESTY_YUM_REPO="https://openresty.org/package/rocky/openresty.repo" --build-arg RESTY_RPM_DIST="el8"
- ./docker_build_and_push_flavor.sh centos-amd64 centos/Dockerfile
- ./docker_build_and_push_flavor.sh centos7-amd64 centos7/Dockerfile
- ./docker_build_and_push_flavor.sh fedora-amd64 fedora/Dockerfile
- ./docker_build_and_push_flavor.sh bullseye-amd64 bullseye/Dockerfile
- ./docker_build_and_push_flavor.sh buster-amd64 buster/Dockerfile
- ./docker_build_and_push_flavor.sh alpine-apk linux/amd64 alpine-apk/Dockerfile
- ./docker_build_and_push_flavor.sh amzn2 linux/amd64 centos/Dockerfile --build-arg RESTY_IMAGE_BASE=amazonlinux --build-arg RESTY_IMAGE_TAG=2 --build-arg RESTY_YUM_REPO="https://openresty.org/package/amazon/openresty.repo" --build-arg RESTY_RPM_DIST="amzn2"
- ./docker_build_and_push_flavor.sh rocky linux/amd64 fedora/Dockerfile --build-arg RESTY_IMAGE_BASE=rockylinux --build-arg RESTY_IMAGE_TAG=8.5 --build-arg RESTY_YUM_REPO="https://openresty.org/package/rocky/openresty.repo" --build-arg RESTY_RPM_DIST="el8"
- ./docker_build_and_push_flavor.sh centos linux/amd64 centos/Dockerfile
- ./docker_build_and_push_flavor.sh centos7 linux/amd64 centos7/Dockerfile
- ./docker_build_and_push_flavor.sh fedora linux/amd64 fedora/Dockerfile
- ./docker_build_and_push_flavor.sh bullseye linux/amd64 bullseye/Dockerfile
- ./docker_build_and_push_flavor.sh buster linux/amd64 buster/Dockerfile

###############################################################################
# Multi-arch manifests
Expand Down
6 changes: 5 additions & 1 deletion docker_build_and_push_flavor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ set -e

FLAVOR="$1"
shift
PLATFORMS="$1"
shift
DOCKERFILE_PATH=${1:-$FLAVOR/Dockerfile}
shift
DOCKER_BUILD_PARAMS="$@"

cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin

docker build --pull -t openresty:$FLAVOR -f $DOCKERFILE_PATH $DOCKER_BUILD_PARAMS .
docker buildx create --use

docker buildx build --pull -t openresty:$FLAVOR --platform "${PLATFORMS}" -f $DOCKERFILE_PATH $DOCKER_BUILD_PARAMS .

if [[ "$TRAVIS_BRANCH" == "master" ]] ; then
cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin &&
Expand Down
7 changes: 7 additions & 0 deletions docker_build_and_push_flavor_fat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ set -e

FLAVOR="$1"
shift
PLATFORMS="$1"
shift
DOCKERFILE_PATH=${1:-$FLAVOR/Dockerfile}
shift
DOCKER_BUILD_PARAMS="$@"

docker buildx create --use

# Compute RESTY_FAT_IMAGE_TAG
FATLESS_FLAVOR=$(echo -n "$FLAVOR" | sed 's/-fat//g')
RESTY_FAT_IMAGE_BASE="$DOCKER_ORG/openresty"
Expand All @@ -31,9 +35,12 @@ fi

cat /tmp/docker.pass | docker login -u="$DOCKER_USERNAME" --password-stdin

docker buildx create --use

docker pull "$RESTY_FAT_IMAGE_BASE:$RESTY_FAT_IMAGE_TAG" || true

docker build --pull -t openresty:$FLAVOR -f $DOCKERFILE_PATH \
--platform "${PLATFORMS}" \
--build-arg "RESTY_FAT_IMAGE_BASE=$RESTY_FAT_IMAGE_BASE" \
--build-arg "RESTY_FAT_IMAGE_TAG=$RESTY_FAT_IMAGE_TAG" \
$DOCKER_BUILD_PARAMS .
Expand Down