Commit 8e47eada authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

Makefile: automatically generate dependencies and rules

Greatly inspired by https://philpep.org/blog/a-makefile-for-your-dockerfiles

This open the way to automatically update variants. However this is not part of
this series.
parent 6b1c70796d46
Pipeline #2593 passed with stage
in 15 seconds
build:
docker build ci-base -t octobus/ci-base
docker build ci-py2 -t octobus/ci-py2
docker build ci-py3 -t octobus/ci-py3
docker build ci-mercurial-core -t octobus/ci-mercurial-core
docker build ci-py2-hgext3rd -t octobus/ci-py2-hgext3rd
docker build ci-py3-hgext3rd -t octobus/ci-py3-hgext3rd
docker build ci-scmperf -t octobus/ci-scmperf
docker build ci-py2-hgext3rd/hg-5.2 -t octobus/ci-py2-hgext3rd:hg-5.2
docker build ci-py2-hgext3rd/hg-5.1 -t octobus/ci-py2-hgext3rd:hg-5.1
docker build ci-py2-hgext3rd/hg-5.0 -t octobus/ci-py2-hgext3rd:hg-5.0
docker build ci-py2-hgext3rd/hg-4.9 -t octobus/ci-py2-hgext3rd:hg-4.9
docker build ci-py2-hgext3rd/hg-4.8 -t octobus/ci-py2-hgext3rd:hg-4.8
docker build ci-py2-hgext3rd/hg-4.7 -t octobus/ci-py2-hgext3rd:hg-4.7
docker build ci-py2-hgext3rd/hg-4.6 -t octobus/ci-py2-hgext3rd:hg-4.6
docker build ci-py2-hgext3rd/hg-4.5 -t octobus/ci-py2-hgext3rd:hg-4.5
docker build ci-py2-hgext3rd/hg-4.4 -t octobus/ci-py2-hgext3rd:hg-4.4
docker build ci-py2-hgext3rd/hg-4.3 -t octobus/ci-py2-hgext3rd:hg-4.3
docker build ci-py2-evolve-doc -t octobus/ci-py2-evolve-doc
docker build ci-py2-docgraph -t octobus/ci-py2-docgraph
docker build ci-py2-docgraph/hg-5.2 -t octobus/ci-py2-docgraph:hg-5.2
docker build ci-py2-docgraph/hg-5.1 -t octobus/ci-py2-docgraph:hg-5.1
docker build ci-py2-docgraph/hg-5.0 -t octobus/ci-py2-docgraph:hg-5.0
docker build ci-py2-docgraph/hg-4.9 -t octobus/ci-py2-docgraph:hg-4.9
docker build ci-py2-docgraph/hg-4.8 -t octobus/ci-py2-docgraph:hg-4.8
docker build ci-py2-docgraph/hg-4.7 -t octobus/ci-py2-docgraph:hg-4.7
docker build ci-py2-docgraph/hg-4.6 -t octobus/ci-py2-docgraph:hg-4.6
docker build ci-py2-docgraph/hg-4.5 -t octobus/ci-py2-docgraph:hg-4.5
docker build ci-py2-docgraph/hg-4.4 -t octobus/ci-py2-docgraph:hg-4.4
docker build ci-py2-format-source -t octobus/ci-py2-format-source
docker build ci-py2-format-source/hg-5.2 -t octobus/ci-py2-format-source:hg-5.2
docker build ci-py2-format-source/hg-5.1 -t octobus/ci-py2-format-source:hg-5.1
docker build ci-py2-format-source/hg-5.0 -t octobus/ci-py2-format-source:hg-5.0
docker build ci-py2-format-source/hg-4.9 -t octobus/ci-py2-format-source:hg-4.9
docker build ci-py2-format-source/hg-4.8 -t octobus/ci-py2-format-source:hg-4.8
docker build ci-py2-format-source/hg-4.7 -t octobus/ci-py2-format-source:hg-4.7
docker build ci-py2-format-source/hg-4.6 -t octobus/ci-py2-format-source:hg-4.6
docker build ci-py2-format-source/hg-4.5 -t octobus/ci-py2-format-source:hg-4.5
docker build ci-py2-format-source/hg-4.4 -t octobus/ci-py2-format-source:hg-4.4
docker build ci-website octobus/ci-website
REGISTRY?=octobus
DOCKERFILES=$(shell find * -type f -name Dockerfile)
IMAGES=$(subst /,\:,$(subst /Dockerfile,,$(DOCKERFILES)))
PUSHES=$(patsubst %,push-%,$(IMAGES))
DEPENDS=.depends.mk
.PHONY: all clean $(IMAGES) $(PUSHES) no-cache
ifeq (no-cache,$(filter no-cache,$(MAKECMDGOALS)))
BUILDOPTS=--no-cache
endif
all: build push
......@@ -41,2 +14,4 @@
clean:
rm -f $(DEPENDS)
......@@ -42,41 +17,15 @@
push:
docker push octobus/ci-base
docker push octobus/ci-py2
docker push octobus/ci-py3
docker push octobus/ci-mercurial-core
docker push octobus/ci-py2-hgext3rd
docker push octobus/ci-py3-hgext3rd
docker push octobus/ci-scmperf
docker push octobus/ci-py2-hgext3rd:hg-4.3
docker push octobus/ci-py2-hgext3rd:hg-4.4
docker push octobus/ci-py2-hgext3rd:hg-4.5
docker push octobus/ci-py2-hgext3rd:hg-4.6
docker push octobus/ci-py2-hgext3rd:hg-4.7
docker push octobus/ci-py2-hgext3rd:hg-4.8
docker push octobus/ci-py2-hgext3rd:hg-4.9
docker push octobus/ci-py2-hgext3rd:hg-5.0
docker push octobus/ci-py2-hgext3rd:hg-5.1
docker push octobus/ci-py2-hgext3rd:hg-5.2
docker push octobus/ci-py2-evolve-doc
docker push octobus/ci-py2-docgraph
docker push octobus/ci-py2-docgraph:hg-5.2
docker push octobus/ci-py2-docgraph:hg-5.1
docker push octobus/ci-py2-docgraph:hg-5.0
docker push octobus/ci-py2-docgraph:hg-4.9
docker push octobus/ci-py2-docgraph:hg-4.8
docker push octobus/ci-py2-docgraph:hg-4.7
docker push octobus/ci-py2-docgraph:hg-4.6
docker push octobus/ci-py2-docgraph:hg-4.5
docker push octobus/ci-py2-docgraph:hg-4.4
docker push octobus/ci-py2-format-source
docker push octobus/ci-py2-docgraph:hg-5.2
docker push octobus/ci-py2-docgraph:hg-5.1
docker push octobus/ci-py2-docgraph:hg-5.0
docker push octobus/ci-py2-docgraph:hg-4.9
docker push octobus/ci-py2-docgraph:hg-4.8
docker push octobus/ci-py2-docgraph:hg-4.7
docker push octobus/ci-py2-docgraph:hg-4.6
docker push octobus/ci-py2-docgraph:hg-4.5
docker push octobus/ci-py2-docgraph:hg-4.4
docker push octobus/ci-website
$(DEPENDS): $(DOCKERFILES) Makefile scripts/generate-depends
scripts/generate-depends $(REGISTRY) $(DOCKERFILES) > $@
sinclude $(DEPENDS)
build: $(IMAGES)
$(IMAGES): %:
docker build $(BUILDOPTS) -t $(REGISTRY)/$@ $(subst :,/,$@)
push: $(PUSHES)
$(PUSHES): %:
docker push $(REGISTRY)/$(patsubst push-%,%,$@)
#!/bin/bash
set -euo pipefail
unset GREP_OPTIONS
REGISTRY=$1
shift
grep "^FROM ${REGISTRY}/" "$@" | \
awk -F "/Dockerfile:FROM ${REGISTRY}/" '{ print $1 " " $2 }' | \
sed 's@[:/]@\\:@g' | awk '{ print $1 ": " $2 }'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment