Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Dockerfiles/Dockerfile.latest
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION} as builder
FROM php:${PHP_VERSION}cli-alpine as builder

# Install build dependencies
RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \
&& apk add --no-cache \
ca-certificates \
# coreutils add 'sort -V'
coreutils \
curl \
git \
&& git clone https://github.com/squizlabs/PHP_CodeSniffer
Expand All @@ -20,10 +21,12 @@ RUN set -eux \
fi \
&& 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
&& mv /phpcs.phar /usr/bin/phpcs \
\
&& phpcs --version


FROM php:${PHP_VERSION} as production
FROM php:${PHP_VERSION}cli-alpine as production
LABEL \
maintainer="cytopia <cytopia@everythingcli.org>" \
repo="https://github.com/cytopia/docker-phpcs"
Expand Down
31 changes: 22 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ DIR = Dockerfiles
ifeq ($(strip $(VERSION)),latest)
PHP_VERSION = latest
PCS_VERSION = latest
IMG_VERSION = ""
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)-
endif

# Extract Image version
ifeq ($(strip $(PHP_VERSION)),latest)
IMG_VERSION = ""
endif

# Building from master branch: Tag == 'latest'
Expand Down Expand Up @@ -89,10 +96,6 @@ FL_IGNORES = .git/,.github/,tests/
SC_IGNORES = .git/,.github/,tests/
JL_IGNORES = .git/,.github/,./tests/

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


# -------------------------------------------------------------------------------------------------
# Default Target
Expand All @@ -118,23 +121,33 @@ help:
.PHONY: docker-pull-base-image
docker-pull-base-image:
@echo "################################################################################"
@echo "# Pulling Base Image php:$(PHP_VERSION) (platform: $(ARCH))"
@echo "# Pulling Base Image php:$(IMG_VERSION)cli-alpine (platform: $(ARCH))"
@echo "################################################################################"
@echo "docker pull --platform $(ARCH) php:$(PHP_VERSION)"; \
while ! docker pull --platform $(ARCH) php:$(PHP_VERSION); do sleep 1; done \
@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=$(PHP_VERSION)
build: ARGS+=--build-arg PHP_VERSION=$(IMG_VERSION)
build: docker-arch-build

.PHONY: rebuild
rebuild: ARGS+=--build-arg PCS_VERSION=$(PCS_VERSION)
rebuild: ARGS+=--build-arg PHP_VERSION=$(PHP_VERSION)
rebuild: ARGS+=--build-arg PHP_VERSION=$(IMG_VERSION)
rebuild: docker-arch-rebuild

.PHONY: push
Expand Down