forked from elastic/apm-agent-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.alpine
61 lines (50 loc) · 2.25 KB
/
Dockerfile.alpine
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
ARG PHP_VERSION=7.2
FROM php:${PHP_VERSION}-fpm-alpine
RUN apk update \
&& apk add \
autoconf \
bash \
build-base \
cmake \
cmocka-dev \
curl \
curl-dev \
git \
logrotate \
procps \
rsyslog \
sqlite-dev \
unzip \
util-linux
ARG ADD_LIBUNWIND_DEPENDENCY=false
RUN echo "ADD_LIBUNWIND_DEPENDENCY: ${ADD_LIBUNWIND_DEPENDENCY}"
ENV ADD_LIBUNWIND_DEPENDENCY=${ADD_LIBUNWIND_DEPENDENCY}
RUN if [[ "${ADD_LIBUNWIND_DEPENDENCY}" = "true" ]] ; then apk add libunwind-dev ; fi
ENV ELASTIC_APM_ASSUME_CAN_CAPTURE_C_STACK_TRACE=${ADD_LIBUNWIND_DEPENDENCY}
RUN docker-php-ext-install \
mysqli \
pcntl \
pdo_mysql \
opcache
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /app/src/ext
ENV REPORT_EXIT_STATUS=1
ENV TEST_PHP_DETAILED=1
ENV NO_INTERACTION=1
ENV TEST_PHP_JUNIT=/app/build/junit.xml
ENV CMOCKA_MESSAGE_OUTPUT=XML
ENV CMOCKA_XML_FILE=/app/build/alpine-${PHP_VERSION}-%g-unit-tests-junit.xml
# Disable agent for auxiliary PHP processes to reduce noise in logs
ENV ELASTIC_APM_ENABLED=false
CMD export CFLAGS="-std=gnu99 ${CFLAGS}" ; \
if [[ "${ADD_LIBUNWIND_DEPENDENCY}" = "true" ]] ; then export LDFLAGS="-lunwind ${LDFLAGS}" ; fi ; \
echo "CFLAGS: ${CFLAGS}, ADD_LIBUNWIND_DEPENDENCY: ${ADD_LIBUNWIND_DEPENDENCY}, LDFLAGS: ${LDFLAGS}" ; \
phpize \
&& ./configure --enable-elastic_apm \
&& make clean \
&& make
# Create a link to extensions directory to make it easier accessible (paths are different between php releases)
RUN ln -s `find /usr/local/lib/php/extensions/ -name opcache.so | head -n1 | xargs dirname` /tmp/extensions
# Patch run-tests.php to handle SKIPIF correctly in tests with agent debug logs enabled
RUN find /usr/local/lib/php/ -name run-tests.php | xargs sed -i 's#if (!strncasecmp(\x27skip\x27, ltrim(\$output), 4))#if (!strncasecmp("skip", ltrim(\$output), 4) || strstr(\$output, "ElasticApmSkipTest"))#g'
RUN find /usr/local/lib/php/ -name run-tests.php | xargs sed -i 's#system_with_timeout("\$extra \$php \$pass_options -q \$ini_settings \$no_file_cache -d display_errors=0 \\"\$test_skipif\\"", \$env)#system_with_timeout("\$extra \$php \$pass_options -q \$ini_settings \$no_file_cache -d display_errors=0 \\"\$test_skipif\\" 2>\&1", \$env)#g'