-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
176 lines (138 loc) · 5.73 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
ARG PHP_VERSION=8.2
ARG FROM_IMAGE=php:${PHP_VERSION}-cli
FROM ${FROM_IMAGE} as build-qa-tools
ARG WITH_COMPOSER_DEPS=""
RUN if [ -n "${WITH_COMPOSER_DEPS}" ]; then \
set -xe; \
apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
&& docker-php-ext-install -j$(nproc) \
zip; \
fi
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME=/usr/local/composer
ENV QA_DEPS_DIR=/usr/local/src
# Default QA tools versions
ARG COMPOSER_UNUSED_VERSION=^0.8
ARG JSONLINT_VERSION=^1
ARG PARALLEL_LINT_VERSION=^1
ARG PDEPEND_VERSION=^2
ARG PHAN_VERSION=^5
ARG PHP_CS_FIXER_VERSION=^3
ARG PHP_CODESNIFFER_VERSION=^3
ARG PHP_DEPRECATION_DETECTOR_VERSION=^2
ARG PHP_INSIGHTS_VERSION=^2
ARG PHP_LOC_VERSION=^7
ARG PHP_MD_VERSION=^2
ARG PHP_METRICS_VERSION=^2
ARG PHP_MND_VERSION=^3
ARG PHPSTAN_VERSION=^1
ARG TWIG_CS_VERSION=^6
ARG YAML_LINTER_VERSION=^6
# Allow custom extensions
ARG PHP_CS_FIXER_EXTENSIONS=""
ARG PHP_CODESNIFFER_EXTENSIONS=""
ARG PHPSTAN_EXTENSIONS=""
RUN set -xe; \
mkdir -p ${QA_DEPS_DIR}; \
cd ${QA_DEPS_DIR}; \
composer init --name=${COMPOSE_PROJECT_NAME:-alximy}/php-qa-tools --no-interaction; \
composer config allow-plugins.bamarni/composer-bin-plugin true; \
composer config extra.bamarni-bin --json '{"bin-links":true, "forward-command":false}'; \
composer config --global allow-plugins.dealerdirect/phpcodesniffer-composer-installer true; \
composer config --global allow-plugins.phpstan/extension-installer true
WORKDIR $QA_DEPS_DIR
RUN composer require --optimize-autoloader \
bamarni/composer-bin-plugin
RUN composer bin composer-unused require --dev --optimize-autoloader \
icanhazstring/composer-unused:$COMPOSER_UNUSED_VERSION
RUN composer bin jsonlint require --dev --optimize-autoloader \
seld/jsonlint:$JSONLINT_VERSION
RUN composer bin parallel-lint require --dev --optimize-autoloader \
php-parallel-lint/php-parallel-lint:$PARALLEL_LINT_VERSION
RUN composer bin pdepend require --dev --optimize-autoloader \
pdepend/pdepend:$PDEPEND_VERSION
RUN composer bin phan require --dev --optimize-autoloader \
phan/phan:$PHAN_VERSION
RUN composer bin php-cs-fixer require --dev --optimize-autoloader \
friendsofphp/php-cs-fixer:$PHP_CS_FIXER_VERSION \
kubawerlos/php-cs-fixer-custom-fixers:* \
$PHP_CS_FIXER_EXTENSIONS
RUN composer bin phpcs require --dev --optimize-autoloader \
squizlabs/php_codesniffer:$PHP_CODESNIFFER_VERSION \
$PHP_CODESNIFFER_EXTENSIONS
RUN composer bin phpdd require --dev --optimize-autoloader \
wapmorgan/php-deprecation-detector:$PHP_DEPRECATION_DETECTOR_VERSION
RUN composer bin phpinsights require --dev --optimize-autoloader \
nunomaduro/phpinsights:$PHP_INSIGHTS_VERSION
RUN composer bin phploc require --dev --optimize-autoloader \
phploc/phploc:$PHP_LOC_VERSION
RUN composer bin phpmd require --dev --optimize-autoloader \
phpmd/phpmd:$PHP_MD_VERSION
RUN composer bin phpmetrics require --dev --optimize-autoloader \
phpmetrics/phpmetrics:$PHP_METRICS_VERSION
RUN composer bin phpmnd require --dev --optimize-autoloader \
povils/phpmnd:$PHP_MND_VERSION
RUN composer bin phpstan require --dev --optimize-autoloader \
phpstan/phpstan:$PHPSTAN_VERSION \
phpstan/extension-installer:* \
phpstan/phpstan-deprecation-rules:* \
phpstan/phpstan-dibi:* \
phpstan/phpstan-doctrine:* \
phpstan/phpstan-phpunit:* \
phpstan/phpstan-beberlei-assert:* \
phpstan/phpstan-strict-rules:* \
phpstan/phpstan-symfony:* \
$PHPSTAN_EXTENSIONS
RUN composer bin twigcs require --dev --optimize-autoloader \
friendsoftwig/twigcs:$TWIG_CS_VERSION
RUN composer bin yaml-lint require --dev --optimize-autoloader \
symfony/console:$YAML_LINTER_VERSION \
symfony/yaml:$YAML_LINTER_VERSION
FROM ${FROM_IMAGE} as build-su-exec
RUN set -ex; \
curl -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c; \
apt-get update && apt-get install -y --no-install-recommends gcc libc-dev; \
gcc -Wall \
/usr/local/bin/su-exec.c -o/usr/local/bin/su-exec; \
chown root:root /usr/local/bin/su-exec; \
chmod 0755 /usr/local/bin/su-exec
FROM ${FROM_IMAGE} as wrap-php
ARG ENABLE_XDEBUG=""
ARG WITH_XDEBUG=""
ARG WITH_AST=""
RUN if [ -n "${WITH_XDEBUG}" ]; then \
pecl install xdebug \
&& echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.client_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
if [ -n "${ENABLE_XDEBUG}" ]; then \
docker-php-ext-enable xdebug; \
fi \
fi
RUN if [ -n "${WITH_AST}" ]; then \
pecl install ast \
&& docker-php-ext-enable ast; \
fi
RUN set -xe; \
apt-get update && apt-get install -y \
bash \
bash-completion \
graphviz
COPY --from=build-qa-tools /usr/local/bin/composer /usr/local/bin/composer
COPY --from=build-qa-tools /usr/local/src /usr/local/src
COPY --from=build-su-exec /usr/local/bin/su-exec /usr/local/bin/
ENV PATH /usr/local/src/vendor/bin:$PATH
ENV QA_VENDOR_PATH /usr/local/src/vendor-bin
RUN set -ex; \
addgroup php-qa-tools; \
adduser php-qa-tools --ingroup php-qa-tools --no-create-home; \
chown -R php-qa-tools:php-qa-tools /usr/local/bin/composer; \
chown -R php-qa-tools:php-qa-tools /usr/local/src/vendor/bin
COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]
LABEL com.alximy.version=1.0
LABEL com.alximy.release-date="2023-08-25"
LABEL com.alximy.author="[email protected]"