Skip to content

Commit 8b050b5

Browse files
authored
Merge pull request DataDog#126 from DataDog/maximo/adding-datadog-plus-otel-php
Adding PHP OTEL + DD Drop In Sandbox
2 parents 74fa95f + e501215 commit 8b050b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3748
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM php:5.6-apache
2+
3+
RUN apt-get update \
4+
# Install base packages
5+
&& apt-get install -y \
6+
apache2 \
7+
curl \
8+
git \
9+
gnupg2 \
10+
libmcrypt-dev \
11+
mysql-client \
12+
unzip \
13+
vim \
14+
wget \
15+
wget \
16+
zlib1g-dev \
17+
# Install relevant php extensions
18+
&& docker-php-source extract \
19+
&& docker-php-ext-install mcrypt \
20+
&& docker-php-ext-install pdo_mysql \
21+
&& docker-php-ext-install pdo \
22+
&& docker-php-ext-install zip \
23+
&& docker-php-source delete \
24+
# Install composer
25+
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
26+
&& php composer-setup.php --install-dir="/usr/bin" --filename=composer \
27+
&& php -r "unlink('composer-setup.php');" \
28+
&& composer self-update \
29+
# Remove installation cache
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
ARG DD_TRACE_VERSION
33+
ARG WEB_APP_PATH
34+
35+
# Install DDTrace deb
36+
ADD https://github.com/DataDog/dd-trace-php/releases/download/${DD_TRACE_VERSION}/datadog-php-tracer_${DD_TRACE_VERSION}-beta_amd64.deb datadog-php-tracer.deb
37+
RUN dpkg -i datadog-php-tracer.deb
38+
39+
RUN a2enmod rewrite
40+
41+
COPY Dockerfiles/apache2.conf /etc/apache2/apache2.conf
42+
COPY Dockerfiles/apache2-virtualhost.conf /etc/apache2/sites-available/000-default.conf
43+
COPY Dockerfiles/php-dd-ext.ini /usr/local/etc/php/conf.d/php-dd-ext.ini
44+
45+
COPY ${WEB_APP_PATH} /var/www
46+
47+
WORKDIR /var/www
48+
49+
RUN chmod -R a+w /var/www
50+
51+
RUN php -d memory_limit=-1 /usr/bin/composer update
52+
53+
CMD [ "apache2-foreground" ]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
FROM php:7.1-fpm
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
git \
6+
libmcrypt-dev \
7+
libmemcached-dev \
8+
mysql-client \
9+
nginx \
10+
procps \
11+
supervisor \
12+
unzip \
13+
valgrind \
14+
vim \
15+
zip \
16+
zlib1g-dev \
17+
&& pecl install mcrypt-1.0.0 \
18+
&& docker-php-ext-enable mcrypt \
19+
&& docker-php-ext-install pcntl \
20+
&& docker-php-ext-enable pcntl \
21+
&& pecl install redis \
22+
&& docker-php-ext-enable redis \
23+
&& pecl install memcached \
24+
&& docker-php-ext-enable memcached \
25+
&& docker-php-ext-install mysqli pdo pdo_mysql \
26+
&& docker-php-ext-enable mysqli \
27+
&& docker-php-ext-enable pdo \
28+
&& docker-php-ext-enable pdo_mysql \
29+
&& docker-php-source delete \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
# Install composer
33+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
34+
&& php composer-setup.php --install-dir="/usr/bin" --filename=composer \
35+
&& php -r "unlink('composer-setup.php');" \
36+
&& composer self-update
37+
38+
ARG DD_TRACE_VERSION
39+
ARG WEB_APP_PATH
40+
41+
COPY ${WEB_APP_PATH} /var/www
42+
43+
# Install DDTrace deb
44+
ADD https://github.com/DataDog/dd-trace-php/releases/download/${DD_TRACE_VERSION}/datadog-php-tracer_${DD_TRACE_VERSION}_amd64.deb datadog-php-tracer.deb
45+
RUN dpkg -i datadog-php-tracer.deb
46+
47+
COPY Dockerfiles/php_nginx_default.conf /etc/nginx/sites-available/default
48+
COPY Dockerfiles/supervisord-nginx-fpm.conf /etc/supervisord.conf
49+
COPY Dockerfiles/php-dd-ext.ini /usr/local/etc/php/conf.d/php-dd-ext.ini
50+
51+
52+
WORKDIR /var/www
53+
54+
RUN chmod -R a+w /var/www
55+
56+
RUN php -d memory_limit=-1 /usr/bin/composer update --no-dev
57+
58+
CMD [ "supervisord", "-n" ]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM php:7.2-fpm
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
apache2 \
6+
git \
7+
libapache2-mod-fastcgi \
8+
libmcrypt-dev \
9+
libmemcached-dev \
10+
mysql-client \
11+
nginx \
12+
procps \
13+
supervisor \
14+
unzip \
15+
valgrind \
16+
vim \
17+
wget \
18+
zip \
19+
zlib1g-dev \
20+
&& pecl install mcrypt-1.0.0 \
21+
&& docker-php-ext-enable mcrypt \
22+
&& docker-php-ext-install pcntl \
23+
&& docker-php-ext-enable pcntl \
24+
&& pecl install redis \
25+
&& docker-php-ext-enable redis \
26+
&& pecl install memcached \
27+
&& docker-php-ext-enable memcached \
28+
&& docker-php-ext-install mysqli pdo pdo_mysql \
29+
&& docker-php-ext-enable mysqli \
30+
&& docker-php-ext-enable pdo \
31+
&& docker-php-ext-enable pdo_mysql \
32+
&& docker-php-source delete \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
# Install composer
36+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
37+
&& php composer-setup.php --install-dir="/usr/bin" --filename=composer \
38+
&& php -r "unlink('composer-setup.php');" \
39+
&& composer self-update
40+
41+
ARG DD_TRACE_VERSION
42+
ARG WEB_APP_PATH
43+
44+
COPY ${WEB_APP_PATH} /var/www
45+
46+
# Install DDTrace deb
47+
ADD https://github.com/DataDog/dd-trace-php/releases/download/${DD_TRACE_VERSION}/datadog-php-tracer_${DD_TRACE_VERSION}-beta_amd64.deb datadog-php-tracer.deb
48+
RUN dpkg -i datadog-php-tracer.deb
49+
50+
COPY Dockerfiles/php_nginx_default.conf /etc/nginx/sites-available/default
51+
COPY Dockerfiles/supervisord-nginx-fpm.conf /etc/supervisord.conf
52+
COPY Dockerfiles/php-dd-ext.ini /usr/local/etc/php/conf.d/php-dd-ext.ini
53+
54+
55+
WORKDIR /var/www
56+
57+
RUN chmod -R a+w /var/www
58+
59+
RUN php -d memory_limit=-1 /usr/bin/composer update --no-dev
60+
61+
CMD [ "supervisord", "-n" ]
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM php:7.2-fpm
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
git \
6+
libmcrypt-dev \
7+
libmemcached-dev \
8+
mysql-client \
9+
nginx \
10+
procps \
11+
supervisor \
12+
unzip \
13+
valgrind \
14+
vim \
15+
zip \
16+
zlib1g-dev \
17+
&& pecl install mcrypt-1.0.0 \
18+
&& docker-php-ext-enable mcrypt \
19+
&& docker-php-ext-install pcntl \
20+
&& docker-php-ext-enable pcntl \
21+
&& pecl install redis \
22+
&& docker-php-ext-enable redis \
23+
&& pecl install memcached \
24+
&& docker-php-ext-enable memcached \
25+
&& docker-php-ext-install mysqli pdo pdo_mysql \
26+
&& docker-php-ext-enable mysqli \
27+
&& docker-php-ext-enable pdo \
28+
&& docker-php-ext-enable pdo_mysql \
29+
&& docker-php-source delete \
30+
&& rm -rf /var/lib/apt/lists/*
31+
32+
RUN apt-get update \
33+
&& docker-php-ext-install opcache \
34+
&& printf "\n" | pecl install apcu \
35+
&& docker-php-source delete
36+
37+
# Install composer
38+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
39+
&& php composer-setup.php --install-dir="/usr/bin" --filename=composer \
40+
&& php -r "unlink('composer-setup.php');" \
41+
&& composer self-update
42+
43+
ARG DD_TRACE_VERSION
44+
ARG WEB_APP_PATH
45+
46+
COPY ${WEB_APP_PATH} /var/www
47+
48+
# Install DDTrace deb
49+
ADD https://github.com/DataDog/dd-trace-php/releases/download/${DD_TRACE_VERSION}/datadog-php-tracer_${DD_TRACE_VERSION}-beta_amd64.deb datadog-php-tracer.deb
50+
RUN dpkg -i datadog-php-tracer.deb
51+
52+
COPY Dockerfiles/php_nginx_default.conf /etc/nginx/sites-available/default
53+
COPY Dockerfiles/supervisord-nginx-fpm.conf /etc/supervisord.conf
54+
COPY Dockerfiles/php-dd-ext.ini /usr/local/etc/php/conf.d/php-dd-ext.ini
55+
COPY Dockerfiles/opcache.ini /usr/local/etc/php/conf.d/opcache-dd-ext.ini
56+
COPY Dockerfiles/acpu.ini /usr/local/etc/php/conf.d/acpu-dd-ext.ini
57+
58+
WORKDIR /var/www
59+
60+
RUN chmod -R a+w /var/www
61+
62+
CMD [ "supervisord", "-n" ]

php/Laravel57/Dockerfiles/acpu.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extension=apcu.so
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<VirtualHost *:80>
2+
</VirtualHost>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
DefaultRuntimeDir ${APACHE_RUN_DIR}
2+
PidFile ${APACHE_PID_FILE}
3+
Timeout 300
4+
KeepAlive On
5+
MaxKeepAliveRequests 100
6+
KeepAliveTimeout 5
7+
8+
# These need to be set in /etc/apache2/envvars
9+
User ${APACHE_RUN_USER}
10+
Group ${APACHE_RUN_GROUP}
11+
12+
HostnameLookups Off
13+
ErrorLog /proc/self/fd/2
14+
CustomLog /proc/self/fd/1 combined
15+
LogLevel warn
16+
17+
# Include module configuration:
18+
IncludeOptional mods-enabled/*.load
19+
IncludeOptional mods-enabled/*.conf
20+
21+
# Include list of ports to listen on
22+
Include ports.conf
23+
24+
DocumentRoot "/var/www/public/"
25+
26+
# Sets the default security model of the Apache2 HTTPD server. It does
27+
# not allow access to the root filesystem outside of /usr/share and /var/www.
28+
# The former is used by web applications packaged in Debian,
29+
# the latter may be used for local directories served by the web server. If
30+
# your system is serving content from a sub-directory in /srv you must allow
31+
# access here, or in any related virtual host.
32+
<Directory />
33+
Options FollowSymLinks
34+
AllowOverride None
35+
Require all denied
36+
</Directory>
37+
38+
<Directory /usr/share>
39+
AllowOverride None
40+
Require all granted
41+
</Directory>
42+
43+
<Directory /var/www/>
44+
Options Indexes FollowSymLinks
45+
AllowOverride None
46+
Require all granted
47+
</Directory>
48+
49+
# AccessFileName: The name of the file to look for in each directory
50+
# for additional configuration directives. See also the AllowOverride
51+
# directive.
52+
#
53+
AccessFileName .htaccess
54+
55+
#
56+
# The following lines prevent .htaccess and .htpasswd files from being
57+
# viewed by Web clients.
58+
#
59+
<FilesMatch "^\.ht">
60+
Require all denied
61+
</FilesMatch>
62+
63+
#
64+
# The following directives define some format nicknames for use with
65+
# a CustomLog directive.
66+
#
67+
# These deviate from the Common Log Format definitions in that they use %O
68+
# (the actual bytes sent including headers) instead of %b (the size of the
69+
# requested file), because the latter makes it impossible to detect partial
70+
# requests.
71+
#
72+
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
73+
# Use mod_remoteip instead.
74+
#
75+
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
76+
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
77+
LogFormat "%h %l %u %t \"%r\" %>s %O" common
78+
LogFormat "%{Referer}i -> %U" referer
79+
LogFormat "%{User-agent}i" agent
80+
81+
# Include of directories ignores editors' and dpkg's backup files,
82+
# see README.Debian for details.
83+
84+
# Include generic snippets of statements
85+
IncludeOptional conf-enabled/*.conf
86+
87+
# Include the virtual host configurations:
88+
IncludeOptional sites-enabled/*.conf
89+
90+
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
opcache.enable=1
2+
opcache.memory_consumption=513
3+
opcache.interned_strings_buffer=32
4+
opcache.max_accelerated_files=32531
5+
opcache.save_comments=1
6+
opcache.validate_timestamps=0
7+
opcache.revalidate_freq=0
8+
opcache.fast_shutdown=1

php/Laravel57/Dockerfiles/opcache.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;zend_extension=opcache.so
2+
opcache.enable=1
3+
opcache.memory_consumption=512
4+
opcache.interned_strings_buffer=32
5+
opcache.max_accelerated_files=32531
6+
opcache.save_comments=1
7+
opcache.validate_timestamps=0
8+
opcache.revalidate_freq=0
9+
opcache.fast_shutdown=1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
date.timezone="UTC"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80;
3+
4+
server_name localhost;
5+
6+
root /var/www/public;
7+
index index.php;
8+
9+
location / {
10+
try_files $uri $uri/ /index.php?$query_string;
11+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
12+
fastcgi_pass 127.0.0.1:9000;
13+
fastcgi_index index.php;
14+
include fastcgi_params;
15+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
16+
fastcgi_param PATH_INFO $fastcgi_path_info;
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:php-fpm]
5+
command=valgrind -q --tool=memcheck --trace-children=yes --vex-iropt-register-updates=allregs-at-mem-access --log-file=/var/www/valgrind.log /usr/local/sbin/php-fpm
6+
process_name=%(program_name)s_%(process_num)02d
7+
stdout_logfile=/dev/stdout
8+
stdout_logfile_maxbytes=0
9+
stderr_logfile=/dev/stderr
10+
stderr_logfile_maxbytes=0
11+
numprocs=1
12+
autostart=true
13+
autorestart=false
14+
15+
[program:nginx]
16+
command=/usr/sbin/nginx -g "daemon off;"
17+
process_name=%(program_name)s_%(process_num)02d
18+
stdout_logfile=/dev/stdout
19+
stdout_logfile_maxbytes=0
20+
stderr_logfile=/dev/stderr
21+
stderr_logfile_maxbytes=0
22+
numprocs=1
23+
autostart=true
24+
autorestart=false

0 commit comments

Comments
 (0)