This repository has been archived by the owner on Jan 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
56 lines (41 loc) · 2 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Makefile for a standard repo with associated image
##### These variables need to be adjusted in most repositories #####
# Base docker org for tag and push
DOCKER_ORG ?= drud
SHELL=/bin/bash
DEFAULT_IMAGES = ddev-php-base ddev-php-prod
BUILD_ARCHS=linux/amd64,linux/arm64
.PHONY: images
# VERSION can be set by
# Default: git tag
# make command line: make VERSION=0.9.0
# It can also be explicitly set in the Makefile as commented out below.
# This version-strategy uses git tags to set the version string
# VERSION can be overridden on make commandline: make VERSION=0.9.1 push
VERSION := $(shell git describe --tags --always --dirty)
BUILDINFO = $(shell echo hash=$$(git rev-parse --short HEAD) Built $$(date) by $${USER} on $$(hostname) $(BUILD_IMAGE) )
# In CI environments, use the plain Docker build progress to not overload the CI logs
PROGRESS := $(if $(CI),plain,auto)
#
# This version-strategy uses a manual value to set the version string
#VERSION := 1.2.3
build: images
images: $(DEFAULT_IMAGES)
$(DEFAULT_IMAGES): .docker-build-info.txt
set -eu -o pipefail; \
DOCKER_BUILDKIT=1 docker buildx build $(BUILDPUSHARG) --platform linux/amd64,linux/arm64 --label com.ddev.buildhost=${shell hostname} --target=$@ -t $(DOCKER_ORG)/$@:$(VERSION) $(DOCKER_ARGS) .
push:
set -eu -o pipefail; \
for item in $(DEFAULT_IMAGES); do \
docker buildx build --push --platform $(BUILD_ARCHS) --label com.ddev.buildhost=${shell hostname} --target=$$item -t $(DOCKER_ORG)/$$item:$(VERSION) $(DOCKER_ARGS) .; \
echo "pushed $(DOCKER_ORG)/$$item:$(VERSION)"; \
done
test: $(DEFAULT_IMAGES)
DOCKER_BUILDKIT=1 docker buildx build --load --platform="linux/$$(./get_arch.sh)" --label com.ddev.buildhost=${shell hostname} -t $(DOCKER_ORG)/$<:$(VERSION) $(DOCKER_ARGS) .
for item in $(DEFAULT_IMAGES); do \
if [ -x tests/$$item/test.sh ]; then tests/$$item/test.sh $(DOCKER_ORG)/$$item:$(VERSION); fi; \
done
version:
@echo VERSION:$(VERSION)
.docker-build-info.txt:
@echo "$(VERSION) $(BUILDINFO)" >.docker-build-info.txt