From 5408b237445624105f757afb55b13ed426df0389 Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 7 Nov 2022 16:20:28 +0100 Subject: [PATCH 1/4] Fix makefile overrides --- Dockerfiles/Dockerfile.latest | 6 +++--- Makefile | 34 +++++++--------------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/Dockerfiles/Dockerfile.latest b/Dockerfiles/Dockerfile.latest index 7860ddd..6b42324 100644 --- a/Dockerfiles/Dockerfile.latest +++ b/Dockerfiles/Dockerfile.latest @@ -1,5 +1,5 @@ -ARG PHP_VERSION -FROM php:${PHP_VERSION}cli-alpine as builder +ARG PHP_IMG_TAG +FROM php:${PHP_IMG_TAG} as builder # Install build dependencies RUN set -eux \ @@ -26,7 +26,7 @@ RUN set -eux \ && phpcs --version -FROM php:${PHP_VERSION}cli-alpine as production +FROM php:${PHP_IMG_TAG} as production LABEL \ maintainer="cytopia " \ repo="https://github.com/cytopia/docker-phpcs" diff --git a/Makefile b/Makefile index 50e8efd..702840f 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ include $(MAKEFILES) # Set default Target .DEFAULT_GOAL := help +DOCKER_PULL_VARIABLES = PHP_IMG_TAG=$(PHP_IMG_TAG) # ------------------------------------------------------------------------------------------------- # Default configuration @@ -32,19 +33,20 @@ FILE = Dockerfile.${FLAVOUR} DIR = Dockerfiles # Extract PHP- and PCS- version from VERSION string +PHP_IMG_TAG = "cli-alpine" ifeq ($(strip $(VERSION)),latest) PHP_VERSION = latest PCS_VERSION = latest - IMG_VERSION = "" + PHP_IMG_TAG = "cli-alpine" else PHP_VERSION = $(subst PHP-,,$(shell echo "$(VERSION)" | grep -Eo 'PHP-([.0-9]+|latest)')) PCS_VERSION = $(subst PCS-,,$(shell echo "$(VERSION)" | grep -Eo 'PCS-([.0-9]+|latest)')) - IMG_VERSION = $(PHP_VERSION)- + PHP_IMG_TAG = $(PHP_VERSION)-cli-alpine endif # Extract Image version ifeq ($(strip $(PHP_VERSION)),latest) - IMG_VERSION = "" + PHP_IMG_TAG = "cli-alpine" endif # Building from master branch: Tag == 'latest' @@ -115,39 +117,17 @@ help: @echo -# ------------------------------------------------------------------------------------------------- -# Target Overrides -# ------------------------------------------------------------------------------------------------- -.PHONY: docker-pull-base-image -docker-pull-base-image: - @echo "################################################################################" - @echo "# Pulling Base Image php:$(IMG_VERSION)cli-alpine (platform: $(ARCH))" - @echo "################################################################################" - @echo "docker pull --platform $(ARCH) php:$(IMG_VERSION)cli-alpine"; \ - SUCC=0; \ - for count in $$(seq 10); do \ - if docker pull --platform $(ARCH) php:$(IMG_VERSION)cli-alpine; then \ - SUCC=1; \ - break; \ - fi; \ - done; \ - if [ "$${SUCC}" != "1" ]; then \ - echo "Failed."; \ - exit 1; \ - fi; - - # ------------------------------------------------------------------------------------------------- # Docker Targets # ------------------------------------------------------------------------------------------------- .PHONY: build build: ARGS+=--build-arg PCS_VERSION=$(PCS_VERSION) -build: ARGS+=--build-arg PHP_VERSION=$(IMG_VERSION) +build: ARGS+=--build-arg PHP_IMG_TAG=$(PHP_IMG_TAG) build: docker-arch-build .PHONY: rebuild rebuild: ARGS+=--build-arg PCS_VERSION=$(PCS_VERSION) -rebuild: ARGS+=--build-arg PHP_VERSION=$(IMG_VERSION) +rebuild: ARGS+=--build-arg PHP_IMG_TAG=$(PHP_IMG_TAG) rebuild: docker-arch-rebuild .PHONY: push From 8860038d667ec010e45d309dba4fab89bc09a383 Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 7 Nov 2022 16:25:22 +0100 Subject: [PATCH 2/4] Trigger builds --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 702840f..ebf07d4 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ include $(MAKEFILES) DOCKER_PULL_VARIABLES = PHP_IMG_TAG=$(PHP_IMG_TAG) + # ------------------------------------------------------------------------------------------------- # Default configuration # ------------------------------------------------------------------------------------------------- From c06f6e6e68e5689956f31709375395b255511818 Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 7 Nov 2022 16:37:59 +0100 Subject: [PATCH 3/4] Fix PHP version test --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ebf07d4..6cbf026 100644 --- a/Makefile +++ b/Makefile @@ -218,7 +218,7 @@ _test-run: .PHONY: _get-php-version _get-php-version: $(eval CURRENT_PHP_VERSION = $(shell \ - if [ "$(PHP)" = "latest" ]; then \ + if [ "$(PHP_VERSION)" = "latest" ]; then \ curl -L -sS https://hub.docker.com/api/content/v1/products/images/php \ | tac | tac \ | grep -Eo '`[.0-9]+-cli-alpine' \ @@ -226,6 +226,6 @@ _get-php-version: | sort -u \ | tail -1; \ else \ - echo $(PHP); \ + echo $(PHP_VERSION); \ fi; \ )) From b2f5b530ea4b4f22c55c6112d6c5d53174ff51ce Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 7 Nov 2022 16:40:28 +0100 Subject: [PATCH 4/4] Fix Dockerfile --- Dockerfiles/Dockerfile.latest | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfiles/Dockerfile.latest b/Dockerfiles/Dockerfile.latest index 6b42324..caf3b01 100644 --- a/Dockerfiles/Dockerfile.latest +++ b/Dockerfiles/Dockerfile.latest @@ -19,6 +19,7 @@ RUN set -eux \ else \ VERSION="$( git tag | grep -E "^v?${PCS_VERSION}\.[.0-9]+\$" | sort -V | tail -1 )"; \ fi \ + && echo "Version: ${VERSION}" \ && curl -sS -L https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${VERSION}/phpcs.phar -o /phpcs.phar \ && chmod +x /phpcs.phar \ && mv /phpcs.phar /usr/bin/phpcs \ @@ -26,6 +27,7 @@ RUN set -eux \ && phpcs --version +ARG PHP_IMG_TAG FROM php:${PHP_IMG_TAG} as production LABEL \ maintainer="cytopia " \