|
| 1 | +# Base Makefile for building all images and tagging them |
| 2 | + |
| 3 | +# By default we only build images for x86_64 architectures. |
| 4 | +_ARCH = x86_64 |
| 5 | + |
| 6 | +# By default we use this user's account on Fedora COPR for where to |
| 7 | +# find the RPMs. You can override this using an environment variable |
| 8 | +# as appropriate. |
| 9 | +USER = ndokos |
| 10 | + |
| 11 | +# By default we use Fedora COPR repos. You can override this default |
| 12 | +# using an environment variable as appropriate. |
| 13 | +URL_PREFIX = https://copr-be.cloud.fedoraproject.org/results/${USER} |
| 14 | + |
| 15 | +# By default we use the pbench Quay.io organization for the image |
| 16 | +# repository. You can override this default using an environment |
| 17 | +# variable as appropriate. |
| 18 | +IMAGE_REPO = docker://quay.io/pbench |
| 19 | + |
| 20 | +# Convenience reference to the repo template in the pbench tree. |
| 21 | +# Not intended to be overridden with an environment variable. |
| 22 | +_REPO_TEMPLATE = ../../ansible/pbench/agent/roles/pbench_repo_install/templates/etc/yum.repos.d/pbench.repo.j2 |
| 23 | + |
| 24 | +# The list of RPMs which provide the various tools we offer. |
| 25 | +# Not intended to be overridden with an environment variable. |
| 26 | +_TOOL_RPMS = pbench-sysstat perf blktrace bpftrace numactl pcp-system-tools strace kernel-tools tcpdump |
| 27 | + |
| 28 | +# The list of RPMs for the default workloads we offer. |
| 29 | +# Not intended to be overridden with an environment variable. |
| 30 | +_WORKLOAD_RPMS = fio uperf |
| 31 | + |
| 32 | +# Not intended to be overridden with an environment variable. |
| 33 | +_ALL_RPMS = ${_TOOL_RPMS} ${_WORKLOAD_RPMS} |
| 34 | + |
| 35 | +# Default we only build images the following distributions: |
| 36 | +all: centos-8-all-tagged centos-7-all-tagged fedora-32-all-tagged fedora-31-all-tagged |
| 37 | + |
| 38 | +#+ |
| 39 | +# Tagging targets |
| 40 | +#- |
| 41 | + |
| 42 | +# Add the "latest" tag to the local images. |
| 43 | +tag-latest: centos-8-tag-latest centos-7-tag-latest fedora-32-tag-latest fedora-31-tag-latest |
| 44 | + |
| 45 | +# Add the "v<Major>-latest" tag to the local images. |
| 46 | +tag-major: centos-8-tag-major centos-7-tag-major fedora-32-tag-major fedora-31-tag-major |
| 47 | + |
| 48 | +# Add the "v<Major>.<Minor>-latest" tag to the local images. |
| 49 | +tag-major-minor: centos-8-tag-major-minor centos-7-tag-major-minor fedora-32-tag-major-minor fedora-31-tag-major-minor |
| 50 | + |
| 51 | +#+ |
| 52 | +# Push targets |
| 53 | +#- |
| 54 | + |
| 55 | +# Push images with "<git commit hash>" and "v<full RPM version>" tags. |
| 56 | +push: centos-8-push centos-7-push fedora-32-push fedora-31-push |
| 57 | + |
| 58 | +# Push images with the "latest" tag. |
| 59 | +push-latest: centos-8-push-latest centos-7-push-latest fedora-32-push-latest fedora-31-push-latest |
| 60 | + |
| 61 | +# Push images with the "v<Major>-latest" tag. |
| 62 | +push-major: centos-8-push-major centos-7-push-major fedora-32-push-major fedora-31-push-major |
| 63 | + |
| 64 | +# Push images with the "v<Major>.<Minor>-latest" tag. |
| 65 | +push-major-minor: centos-8-push-major-minor centos-7-push-major-minor fedora-32-push-major-minor fedora-31-push-major-minor |
| 66 | + |
| 67 | +#+ |
| 68 | +# For the following rule patterns, the "%" represents the "distribution" name, |
| 69 | +# as derived from the "all" target's *-distro list. |
| 70 | +#- |
| 71 | + |
| 72 | +%-all-tagged: %-all %-tags.lis |
| 73 | + ./apply-tags pbench-agent-all-${@:-all-tagged=} ${@:-all-tagged=}-tags.lis |
| 74 | + |
| 75 | +%-all: %-tools-tagged %-workloads-tagged %-all.Dockerfile |
| 76 | + ./build-image all ${@:-all=} ${@:-all=}-tags.lis |
| 77 | + |
| 78 | +%-all.Dockerfile: Dockerfile.layered.j2 %-tags.lis |
| 79 | + jinja2 Dockerfile.layered.j2 -D distro=${@:-all.Dockerfile=} -D tag="$$(grep -v -E '^v' ${@:-all.Dockerfile=}-tags.lis)" -D kind="all" -D rpms="${_ALL_RPMS}" > ./$@ |
| 80 | + |
| 81 | +%-tools-tagged: %-tools %-tags.lis |
| 82 | + ./apply-tags pbench-agent-tools-${@:-tools-tagged=} ${@:-tools-tagged=}-tags.lis |
| 83 | + |
| 84 | +%-tools: %-base-tagged %-tools.Dockerfile |
| 85 | + ./build-image tools ${@:-tools=} ${@:-tools=}-tags.lis |
| 86 | + |
| 87 | +%-tools.Dockerfile: Dockerfile.layered.j2 %-tags.lis |
| 88 | + jinja2 Dockerfile.layered.j2 -D distro=${@:-tools.Dockerfile=} -D tag="$$(grep -v -E '^v' ${@:-tools.Dockerfile=}-tags.lis)" -D kind="tools" -D rpms="${_TOOL_RPMS}" > ./$@ |
| 89 | + |
| 90 | +%-workloads-tagged: %-workloads %-tags.lis |
| 91 | + ./apply-tags pbench-agent-workloads-${@:-workloads-tagged=} ${@:-workloads-tagged=}-tags.lis |
| 92 | + |
| 93 | +%-workloads: %-base-tagged %-workloads.Dockerfile |
| 94 | + ./build-image workloads ${@:-workloads=} ${@:-workloads=}-tags.lis |
| 95 | + |
| 96 | +%-workloads.Dockerfile: Dockerfile.layered.j2 %-tags.lis |
| 97 | + jinja2 Dockerfile.layered.j2 -D distro=${@:-workloads.Dockerfile=} -D tag="$$(grep -v -E '^v' ${@:-workloads.Dockerfile=}-tags.lis)" -D kind="workloads" -D rpms="${_WORKLOAD_RPMS}" > ./$@ |
| 98 | + |
| 99 | +%-base-tagged: %-base |
| 100 | + ./apply-tags pbench-agent-base-${@:-base-tagged=} ${@:-base-tagged=}-tags.lis |
| 101 | + |
| 102 | +%-base: %-base.Dockerfile %-tags.lis |
| 103 | + ./build-image base ${@:-base=} ${@:-base=}-tags.lis |
| 104 | + |
| 105 | +#+ |
| 106 | +# Push local images for the given tag and distribution. |
| 107 | +#- |
| 108 | + |
| 109 | +%-push: %-tags.lis |
| 110 | + ./push ${IMAGE_REPO} ${@:-push=} |
| 111 | + |
| 112 | +%-push-latest: %-tags.lis |
| 113 | + ./push ${IMAGE_REPO} ${@:-push-latest=} latest |
| 114 | + |
| 115 | +%-push-major: %-tags.lis |
| 116 | + ./push ${IMAGE_REPO} ${@:-push-major=} _major |
| 117 | + |
| 118 | +%-push-major-minor: %-tags.lis |
| 119 | + ./push ${IMAGE_REPO} ${@:-push-major-minor=} _minor |
| 120 | + |
| 121 | +#+ |
| 122 | +# Tag local images for the given distribution. |
| 123 | +#- |
| 124 | + |
| 125 | +%-tag-latest: %-tags.lis |
| 126 | + ./tagit ${@:-tag-latest=} latest |
| 127 | + |
| 128 | +%-tag-major: %-tags.lis |
| 129 | + ./tagit ${@:-tag-major=} major-latest |
| 130 | + |
| 131 | +%-tag-major-minor: %-tags.lis |
| 132 | + ./tagit ${@:-tag-major-minor=} major-minor-latest |
| 133 | + |
| 134 | +# Build the tags file for the given distribution. |
| 135 | +%-tags.lis: |
| 136 | + ./gen-tags-from-rpm "${URL_PREFIX}" "${@:-tags.lis=}" "${_ARCH}" > ${@} |
| 137 | + |
| 138 | +#+ |
| 139 | +# For the following rules, the various CentOS "base" images need a mapping |
| 140 | +# between the distribution name and the repo name, which for CentOS images |
| 141 | +# is "epel". And for both CentOS and Fedora, the distribution image |
| 142 | +# reference, the package manager (dnf vs yum), and image name, also require |
| 143 | +# mappings (e.g. centos-7 -> yum, centos:7, CentOS 7, fedora-32 -> dnf, |
| 144 | +# fedora:32, Fedora 32). |
| 145 | +#- |
| 146 | +centos-8-base.Dockerfile: Dockerfile.base.j2 epel-8-pbench.repo |
| 147 | + jinja2 Dockerfile.base.j2 -D pbench_repo_file=epel-8-pbench.repo -D pkgmgr=dnf -D distro_image=centos:8 -D distro_image_name="CentOS 8" -o $@ |
| 148 | + |
| 149 | +centos-7-base.Dockerfile: Dockerfile.base.j2 epel-7-pbench.repo |
| 150 | + jinja2 Dockerfile.base.j2 -D pbench_repo_file=epel-7-pbench.repo -D pkgmgr=yum -D distro_image=centos:7 -D distro_image_name="CentOS 7" -o $@ |
| 151 | + |
| 152 | +fedora-32-base.Dockerfile: Dockerfile.base.j2 fedora-32-pbench.repo |
| 153 | + jinja2 Dockerfile.base.j2 -D pbench_repo_file=fedora-32-pbench.repo -D pkgmgr=dnf -D distro_image=fedora:32 -D distro_image_name="Fedora 32" -o $@ |
| 154 | + |
| 155 | +fedora-31-base.Dockerfile: Dockerfile.base.j2 fedora-31-pbench.repo |
| 156 | + jinja2 Dockerfile.base.j2 -D pbench_repo_file=fedora-31-pbench.repo -D pkgmgr=dnf -D distro_image=fedora:31 -D distro_image_name="Fedora 31" -o $@ |
| 157 | + |
| 158 | +# Rule pattern dependencies on non-patterned targets have to be set up |
| 159 | +# separately for some reason. |
| 160 | +%.repo: ${_REPO_TEMPLATE} |
| 161 | + |
| 162 | +%.repo: %.yml |
| 163 | + jinja2 ${_REPO_TEMPLATE} ${@:.repo=}.yml -o $@ |
| 164 | + |
| 165 | +%.yml: repo.yml.j2 |
| 166 | + jinja2 repo.yml.j2 -D distro=${@:-pbench.yml=} -D url_prefix=${URL_PREFIX} -o $@ |
| 167 | + |
| 168 | +clean: |
| 169 | + rm -f *.Dockerfile *.repo *.yml *-tags.lis |
0 commit comments