Skip to content

Commit

Permalink
Merge pull request #15 from cytopia/release-0.7
Browse files Browse the repository at this point in the history
Fix makefile overrides
  • Loading branch information
cytopia authored Nov 7, 2022
2 parents 4e55579 + b2f5b53 commit 3b17489
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
8 changes: 5 additions & 3 deletions Dockerfiles/Dockerfile.latest
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -19,14 +19,16 @@ 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 \
\
&& phpcs --version


FROM php:${PHP_VERSION}cli-alpine as production
ARG PHP_IMG_TAG
FROM php:${PHP_IMG_TAG} as production
LABEL \
maintainer="cytopia <cytopia@everythingcli.org>" \
repo="https://github.com/cytopia/docker-phpcs"
Expand Down
39 changes: 10 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ include $(MAKEFILES)
# Set default Target
.DEFAULT_GOAL := help

DOCKER_PULL_VARIABLES = PHP_IMG_TAG=$(PHP_IMG_TAG)


# -------------------------------------------------------------------------------------------------
# Default configuration
Expand All @@ -32,19 +34,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'
Expand Down Expand Up @@ -115,39 +118,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
Expand Down Expand Up @@ -237,14 +218,14 @@ _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' \
| grep -Eo '[.0-9]+' \
| sort -u \
| tail -1; \
else \
echo $(PHP); \
echo $(PHP_VERSION); \
fi; \
))

0 comments on commit 3b17489

Please sign in to comment.