Make php 7.0 cs fixer

This commit is contained in:
Arnie 2018-11-19 19:31:44 +01:00
parent 9fc9241c47
commit 75be9aef27
5 changed files with 58 additions and 7 deletions

View File

@ -1,4 +1,4 @@
FROM node:8-slim
FROM node:8-stretch
# https support
RUN apt-get update && \
@ -8,7 +8,7 @@ RUN apt-get update && \
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn php5-cli && \
apt-get install -y yarn php7.0-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/* /tmp/* /var/tmp/*

View File

@ -0,0 +1,41 @@
FROM node:8-slim
# https support
RUN apt-get update && \
apt-get install -y apt-transport-https ca-certificates
# add yarn and php
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn php5-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/* /tmp/* /var/tmp/*
# add php fixer
RUN curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.10.0/php-cs-fixer.phar -o /usr/local/bin/php-cs-fixer && \
chmod a+x /usr/local/bin/php-cs-fixer
WORKDIR /app
# add csscomb and prettier
RUN yarn add prettier csscomb --global && \
ln -s /app/node_modules/.bin/prettier /usr/local/bin/prettier && \
ln -s /app/node_modules/.bin/csscomb /usr/local/bin/csscomb
COPY ["src/entry.sh", "/app/entry.sh"]
COPY ["src/inc", "/app/inc"]
WORKDIR /code
CMD ["/app/entry.sh"]
ENTRYPOINT ["/app/entry.sh"]
ARG VERSION
ARG COMMIT_SHA
ENV VERSION=$VERSION
ENV COMMIT_SHA=$COMMIT_SHA

View File

@ -17,13 +17,15 @@ GIT_TAG = $(shell git describe --tags --exact-match 2>/dev/null)
VERSION := $(or $(GIT_TAG),latest)
all : VERSION := 1.0.1
all : VERSION := 1.0.2
all : build release
.PHONY : all
build :
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION) .
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.2 .
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT_SHA=$(COMMIT) -t $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php5.6 .
docker tag $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)-php7.2 $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)
release : build
docker push $(DOCKER_REGISTRY)/$(APP_NAME):$(VERSION)

View File

@ -3,13 +3,18 @@
__phpFixer() {
local failed=0
local args=""
__msg "PHP-cs-fixer"
if [[ ${VERBOSE} -eq 1 ]]; then
args="${args} -vvv"
fi
# Cannot chain php files without specifying a config CS file :(
if [[ ${DRY_RUN} -eq 0 ]]; then
for file in "${PHP_FILES[@]}"; do
php-cs-fixer fix "${file}"
php-cs-fixer ${args} fix "${file}"
[[ $? -ne 0 ]] && failed=1
done
else
@ -17,7 +22,7 @@ __phpFixer() {
local invalid_syntax=()
for file in "${PHP_FILES[@]}"; do
php-cs-fixer fix --dry-run "${file}"
php-cs-fixer ${args} fix --dry-run "${file}"
case $? in
0)
#all good

View File

@ -11,7 +11,7 @@ PHP_FILES=()
DRY_RUN=0
VERBOSE=0
__initVariables() {
@ -21,6 +21,9 @@ __initVariables() {
--dry-run)
DRY_RUN=1
;;
--verbose)
VERBOSE=1
;;
*.css|*.scss|*.sass|*.less)
__path_exists "${1}"
if [[ $? -ne 0 ]]; then