Skip to content

Commit d59c8c4

Browse files
authored
Merge pull request #8 from cytopia/release-0.5
FIx docker build
2 parents 81fac78 + 6999b12 commit d59c8c4

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

Dockerfiles/Dockerfile.latest

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
ARG PHP_VERSION
2-
FROM php:${PHP_VERSION} as builder
1+
ARG PHP_IMG_TAG
2+
FROM php:${PHP_IMG_TAG} as builder
33

44
# Install build dependencies
55
RUN set -eux \
6-
&& DEBIAN_FRONTEND=noninteractive apt-get update -qq \
7-
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \
6+
&& apk add --no-cache \
87
ca-certificates \
8+
# coreutils add 'sort -V'
9+
coreutils \
910
curl \
1011
git \
1112
&& git clone https://github.com/squizlabs/PHP_CodeSniffer
@@ -18,12 +19,16 @@ RUN set -eux \
1819
else \
1920
VERSION="$( git tag | grep -E "^v?${PBF_VERSION}\.[.0-9]+\$" | sort -V | tail -1 )"; \
2021
fi \
22+
&& echo "Version: ${VERSION}" \
2123
&& curl -sS -L https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${VERSION}/phpcbf.phar -o /phpcbf.phar \
2224
&& chmod +x /phpcbf.phar \
23-
&& mv /phpcbf.phar /usr/bin/phpcbf
25+
&& mv /phpcbf.phar /usr/bin/phpcbf \
26+
\
27+
&& phpcbf --version
2428

2529

26-
FROM php:${PHP_VERSION} as production
30+
ARG PHP_IMG_TAG
31+
FROM php:${PHP_IMG_TAG} as production
2732
LABEL \
2833
maintainer="cytopia <cytopia@everythingcli.org>" \
2934
repo="https://github.com/cytopia/docker-phpcbf"

Makefile

+13-20
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ include $(MAKEFILES)
1616
# Set default Target
1717
.DEFAULT_GOAL := help
1818

19+
DOCKER_PULL_VARIABLES = PHP_IMG_TAG=$(PHP_IMG_TAG)
20+
1921

2022
# -------------------------------------------------------------------------------------------------
2123
# Default configuration
@@ -35,9 +37,16 @@ DIR = Dockerfiles
3537
ifeq ($(strip $(VERSION)),latest)
3638
PHP_VERSION = latest
3739
PBF_VERSION = latest
40+
PHP_IMG_TAG = "cli-alpine"
3841
else
3942
PHP_VERSION = $(subst PHP-,,$(shell echo "$(VERSION)" | grep -Eo 'PHP-([.0-9]+|latest)'))
4043
PBF_VERSION = $(subst PBF-,,$(shell echo "$(VERSION)" | grep -Eo 'PBF-([.0-9]+|latest)'))
44+
PHP_IMG_TAG = $(PHP_VERSION)-cli-alpine
45+
endif
46+
47+
# Extract Image version
48+
ifeq ($(strip $(PHP_VERSION)),latest)
49+
PHP_IMG_TAG = "cli-alpine"
4150
endif
4251

4352
# Building from master branch: Tag == 'latest'
@@ -89,10 +98,6 @@ FL_IGNORES = .git/,.github/,tests/
8998
SC_IGNORES = .git/,.github/,tests/
9099
JL_IGNORES = .git/,.github/,./tests/
91100

92-
out:
93-
@echo "PHP: $(subst PHP-,,$(shell echo "$(VERSION)" | grep -Eo 'PHP-[.0-9]+'))"
94-
@echo "PCS: $(subst PCS-,,$(shell echo "$(VERSION)" | grep -Eo 'PCS-[.0-9]+'))"
95-
96101

97102
# -------------------------------------------------------------------------------------------------
98103
# Default Target
@@ -112,29 +117,17 @@ help:
112117
@echo
113118

114119

115-
# -------------------------------------------------------------------------------------------------
116-
# Target Overrides
117-
# -------------------------------------------------------------------------------------------------
118-
.PHONY: docker-pull-base-image
119-
docker-pull-base-image:
120-
@echo "################################################################################"
121-
@echo "# Pulling Base Image php:$(PHP_VERSION) (platform: $(ARCH))"
122-
@echo "################################################################################"
123-
@echo "docker pull --platform $(ARCH) php:$(PHP_VERSION)"; \
124-
while ! docker pull --platform $(ARCH) php:$(PHP_VERSION); do sleep 1; done \
125-
126-
127120
# -------------------------------------------------------------------------------------------------
128121
# Docker Targets
129122
# -------------------------------------------------------------------------------------------------
130123
.PHONY: build
131124
build: ARGS+=--build-arg PBF_VERSION=$(PBF_VERSION)
132-
build: ARGS+=--build-arg PHP_VERSION=$(PHP_VERSION)
125+
build: ARGS+=--build-arg PHP_IMG_TAG=$(PHP_IMG_TAG)
133126
build: docker-arch-build
134127

135128
.PHONY: rebuild
136129
rebuild: ARGS+=--build-arg PBF_VERSION=$(PBF_VERSION)
137-
rebuild: ARGS+=--build-arg PHP_VERSION=$(PHP_VERSION)
130+
rebuild: ARGS+=--build-arg PHP_IMG_TAG=$(PHP_IMG_TAG)
138131
rebuild: docker-arch-rebuild
139132

140133
.PHONY: push
@@ -224,14 +217,14 @@ _test-run:
224217
.PHONY: _get-php-version
225218
_get-php-version:
226219
$(eval CURRENT_PHP_VERSION = $(shell \
227-
if [ "$(PHP)" = "latest" ]; then \
220+
if [ "$(PHP_VERSION)" = "latest" ]; then \
228221
curl -L -sS https://hub.docker.com/api/content/v1/products/images/php \
229222
| tac | tac \
230223
| grep -Eo '`[.0-9]+-cli-alpine' \
231224
| grep -Eo '[.0-9]+' \
232225
| sort -u \
233226
| tail -1; \
234227
else \
235-
echo $(PHP); \
228+
echo $(PHP_VERSION); \
236229
fi; \
237230
))

0 commit comments

Comments
 (0)