github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/containers/ddev-php-base/Makefile (about)

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