docker.yml revision 14b11b2b
1spec: 2 inputs: 3 targets: 4 description: 5 List of build targets in form of "OS-ARCH" pair (e.g., linux-amd64). 6 Mostly the same as platform string for Docker but with a hyphen instead 7 of slash. 8 type: array 9 job_name_prefix: 10 description: 11 Additional prefix for the job name. Can be used to disable a job with a 12 "." prefix. 13 default: "" 14 job_name_suffix: 15 description: 16 Additional suffix for the job name. Can be used to prevent job 17 duplication for jobs for the same target or running on a different 18 target. 19 default: "" 20 runner_tags: 21 description: List of GitLab runner tags for this job. 22 type: array 23 default: [] 24 25--- 26 27"$[[ inputs.job_name_prefix ]]docker$[[ inputs.job_name_suffix ]]": 28 stage: docker 29 image: quay.io/buildah/stable 30 rules: 31 - if: "$CI_PIPELINE_SOURCE == 'merge_request_event' && $TARGET =~ $ACTIVE_TARGET_PATTERN" 32 changes: 33 paths: 34 - .gitlab-ci.d/01-docker.yml 35 - .gitlab-ci.d/01-docker/**/* 36 variables: 37 DOCKER_TAG: $CI_COMMIT_REF_SLUG 38 DOCKER_IMAGE_NAME: ${CI_REGISTRY_IMAGE}/pixman:${DOCKER_TAG} 39 - if: "$CI_PIPELINE_SOURCE == 'schedule' && $TARGET =~ $ACTIVE_TARGET_PATTERN" 40 - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $TARGET =~ $ACTIVE_TARGET_PATTERN" 41 - if: "$CI_COMMIT_TAG && $TARGET =~ $ACTIVE_TARGET_PATTERN" 42 tags: $[[ inputs.runner_tags ]] 43 44 variables: 45 # Use vfs with buildah. Docker offers overlayfs as a default, but Buildah 46 # cannot stack overlayfs on top of another overlayfs filesystem. 47 STORAGE_DRIVER: vfs 48 49 # Write all image metadata in the docker format, not the standard OCI 50 # format. Newer versions of docker can handle the OCI format, but older 51 # versions, like the one shipped with Fedora 30, cannot handle the format. 52 BUILDAH_FORMAT: docker 53 54 BUILDAH_ISOLATION: chroot 55 CACHE_IMAGE: ${CI_REGISTRY_IMAGE}/cache 56 CACHE_ARGS: --cache-from ${CACHE_IMAGE} --cache-to ${CACHE_IMAGE} 57 before_script: 58 # Login to the target registry. 59 - echo "${CI_REGISTRY_PASSWORD}" | 60 buildah login -u "${CI_REGISTRY_USER}" --password-stdin ${CI_REGISTRY} 61 62 # Docker Hub login is optional, and can be used to circumvent image pull 63 # quota for anonymous pulls for base images. 64 - echo "${DOCKERHUB_PASSWORD}" | 65 buildah login -u "${DOCKERHUB_USER}" --password-stdin docker.io || 66 echo "Failed to login to Docker Hub." 67 parallel: 68 matrix: 69 - TARGET: $[[ inputs.targets ]] 70 script: 71 # Prepare environment. 72 - ${LOAD_TARGET_ENV} 73 - FULL_IMAGE_NAME=${DOCKER_IMAGE_NAME}-${TARGET} 74 75 # Build and push the image. 76 - buildah bud 77 --tag ${FULL_IMAGE_NAME} 78 --layers ${CACHE_ARGS} 79 --target ${TARGET} 80 --platform=${DOCKER_PLATFORM} 81 --build-arg BASE_IMAGE=${BASE_IMAGE} 82 --build-arg BASE_IMAGE_TAG=${BASE_IMAGE_TAG} 83 --build-arg LLVM_VERSION=${LLVM_VERSION} 84 -f Dockerfile .gitlab-ci.d/01-docker/ 85 - buildah images 86 - buildah push ${FULL_IMAGE_NAME} 87