[Docker]Php代码相关的检测工具

phpstan

FROM alpine:3.9

LABEL maintainer="Karoy Docker Maintainers <docker-maint@karoy.cn>"

ENV COMPOSER_HOME /composer
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV PATH /composer/vendor/bin:$PATH

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apk --update --no-cache add \
    php7 \
    php7-ctype \
    php7-curl \
    php7-dom \
    php7-fileinfo \
    php7-ftp \
    php7-iconv \
    php7-json \
    php7-mbstring \
    php7-mysqlnd \
    php7-openssl \
    php7-pdo \
    php7-pdo_sqlite \
    php7-phar \
    php7-posix \
    php7-session \
    php7-simplexml \
    php7-sqlite3 \
    php7-tokenizer \
    php7-xml \
    php7-xmlreader \
    php7-xmlwriter \
    php7-zlib \
    && echo "memory_limit=-1" > /etc/php7/conf.d/99_memory-limit.ini \
    && rm -rf /var/cache/apk/* /var/tmp/* /tmp/*

RUN composer global require phpstan/phpstan-shim

VOLUME ["/app"]
WORKDIR /app

ENTRYPOINT ["phpstan"]
1
2
docker build -t karoy.cn/karoy/phpstan:latest .
docker run --rm -v /src:/app karoy.cn/karoy/phpstan:latest analyse /app

phpmd

FROM alpine:3.9

LABEL maintainer="Karoy Docker Maintainers <docker-maint@karoy.cn>"

ENV COMPOSER_HOME /composer
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV PATH /composer/vendor/bin:$PATH

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apk --update --no-cache add \
    php7 \
    php7-ctype \
    php7-curl \
    php7-dom \
    php7-fileinfo \
    php7-ftp \
    php7-iconv \
    php7-json \
    php7-mbstring \
    php7-mysqlnd \
    php7-openssl \
    php7-pdo \
    php7-pdo_sqlite \
    php7-phar \
    php7-posix \
    php7-session \
    php7-simplexml \
    php7-sqlite3 \
    php7-tokenizer \
    php7-xml \
    php7-xmlreader \
    php7-xmlwriter \
    php7-zlib \
    && echo "memory_limit=-1" > /etc/php7/conf.d/99_memory-limit.ini \
    && rm -rf /var/cache/apk/* /var/tmp/* /tmp/*

ARG PHPSTAN_VERSION

RUN composer global require phpmd/phpmd

VOLUME ["/app"]
WORKDIR /app

ENTRYPOINT ["phpmd"]
1
2
docker build -t karoy.cn/karoy/phpmd:latest .
docker run --rm -v /src:/app karoy.cn/karoy/phpmd:latest /app html codesize,unusedcode,naming --reportfile /app/phpmd.html --suffixes php,phtml

phpcs

FROM alpine:3.9

LABEL maintainer="Karoy Docker Maintainers <docker-maint@karoy.cn>"

ENV COMPOSER_HOME /composer
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV PATH /composer/vendor/bin:$PATH

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apk --update --no-cache add \
    php7 \
    php7-ctype \
    php7-curl \
    php7-dom \
    php7-fileinfo \
    php7-ftp \
    php7-iconv \
    php7-json \
    php7-mbstring \
    php7-mysqlnd \
    php7-openssl \
    php7-pdo \
    php7-pdo_sqlite \
    php7-phar \
    php7-posix \
    php7-session \
    php7-simplexml \
    php7-sqlite3 \
    php7-tokenizer \
    php7-xml \
    php7-xmlreader \
    php7-xmlwriter \
    php7-zlib \
    && echo "memory_limit=-1" > /etc/php7/conf.d/99_memory-limit.ini \
    && rm -rf /var/cache/apk/* /var/tmp/* /tmp/*

ARG PHPSTAN_VERSION

RUN composer global require "squizlabs/php_codesniffer=*"

VOLUME ["/app"]
WORKDIR /app

ENTRYPOINT ["phpcs"]
1
2
docker build -t karoy.cn/karoy/phpcs:latest .
docker run --rm -v /src:/app karoy.cn/karoy/phpcs:latest --report=full /app

phpcbf

FROM alpine:3.9

LABEL maintainer="Karoy Docker Maintainers <docker-maint@karoy.cn>"

ENV COMPOSER_HOME /composer
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV PATH /composer/vendor/bin:$PATH

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apk --update --no-cache add \
    php7 \
    php7-ctype \
    php7-curl \
    php7-dom \
    php7-fileinfo \
    php7-ftp \
    php7-iconv \
    php7-json \
    php7-mbstring \
    php7-mysqlnd \
    php7-openssl \
    php7-pdo \
    php7-pdo_sqlite \
    php7-phar \
    php7-posix \
    php7-session \
    php7-simplexml \
    php7-sqlite3 \
    php7-tokenizer \
    php7-xml \
    php7-xmlreader \
    php7-xmlwriter \
    php7-zlib \
    && echo "memory_limit=-1" > /etc/php7/conf.d/99_memory-limit.ini \
    && rm -rf /var/cache/apk/* /var/tmp/* /tmp/*

ARG PHPSTAN_VERSION

RUN composer global require "squizlabs/php_codesniffer=*"

VOLUME ["/app"]
WORKDIR /app

ENTRYPOINT ["phpcbf"]
1
2
docker build -t karoy.cn/karoy/phpcbf:latest .
docker run --rm -v /src:/app karoy.cn/karoy/phpcbf:latest /app