.make-image-envs: &make-image-envs - name: set NAMESPACE script: echo -n "$CNB_REPO_SLUG" | cut -d "/" -f3 exports: info: NAMESPACE - name: set IMAGE_NAME script: echo -n "$CNB_REPO_SLUG" | cut -d "/" -f4 exports: info: IMAGE_NAME - name: set IMAGE_VERSION script: echo -n "$CNB_BRANCH" | cut -d "/" -f1 exports: info: IMAGE_VERSION - name: use latest if main if: | [ "$CNB_BRANCH" = "main" ] script: echo -n "latest" exports: info: IMAGE_VERSION - name: set IMAGE_TAG script: echo -n "${NAMESPACE}/${IMAGE_NAME}:${IMAGE_VERSION}" exports: info: IMAGE_TAG .build-by-arch: &build-by-arch - name: docker login for index.docker.io script: docker login -u "$DOCKER_USER" -p "$DOCKER_PWD" imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml - name: set DOCKERFILE_DIR script: | if [ -f "docker/Dockerfile.linux.$BUILD_ARCH" ]; then echo -n "docker/Dockerfile.linux.$BUILD_ARCH" else echo -n "Dockerfile" fi exports: info: DOCKERFILE_DIR - name: docker build & push if: | [ -f $DOCKERFILE_DIR ] script: - docker build -f $DOCKERFILE_DIR -t $IMAGE_TAG-linux-$BUILD_ARCH . - docker push $IMAGE_TAG-linux-$BUILD_ARCH - name: resolve type: cnb:resolve options: key: build-$BUILD_ARCH .amd64-arch-build: &amd64-arch-build name: build-amd64 runner: tags: cnb:arch:amd64 services: - docker env: BUILD_ARCH: amd64 stages: - *make-image-envs - *build-by-arch .arm64-arch-build: &arm64-arch-build name: build-arm64 runner: tags: cnb:arch:arm64:v8 env: BUILD_ARCH: arm64 services: - docker stages: - *make-image-envs - *build-by-arch .multi-arch-push: &multi-arch-push - name: await the amd64 type: cnb:await options: key: build-amd64 - name: await the arm64 type: cnb:await options: key: build-arm64 - name: manifest image: plugins/manifest settings: username: $DOCKER_USER password: $DOCKER_PWD target: $IMAGE_TAG template: ${IMAGE_TAG}-OS-ARCH # ignore_missing: true platforms: - linux/amd64 - linux/arm64 - name: clear image: lumir/remove-dockerhub-tag args: - --user - $DOCKER_USER - --password - $DOCKER_PWD - ${IMAGE_TAG}-linux-amd64 - ${IMAGE_TAG}-linux-arm64 "(main|dev|staging)": push: - *amd64-arch-build - *arm64-arch-build - name: conbine-arch imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml services: - docker stages: - *make-image-envs - *multi-arch-push $: tag_push: - *amd64-arch-build - *arm64-arch-build - name: conbine-arch imports: https://cnb.cool/cnb/secrets/-/blob/main/envs/hub.docker.com.yml services: - docker stages: - *make-image-envs - *multi-arch-push