-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
74 lines (62 loc) · 3.6 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
ARG PHP_VERSION=8.2
# Set a BASE_IMAGE CI var to specify a different base image without a tag
ARG BASE_IMAGE=ghcr.io/10up/base-php
ARG UBUNTU_RELEASE_NAME=jammy
FROM ${BASE_IMAGE}:${PHP_VERSION}-${UBUNTU_RELEASE_NAME}
ARG PHP_VERSION=8.2
ARG TARGETPLATFORM
ENV PHP_VERSION=${PHP_VERSION}
USER root
RUN apt-get update; apt install php${PHP_VERSION}-fpm msmtp curl -y && apt clean all; rm -rf /var/lib/apt/lists/*
# Routine to install newrelic agent
RUN \
if [[ "${TARGETPLATFORM}" = "linux/arm64" ]] || [[ "$(uname -m)" = "aarch64" ]]; then exit 0; fi ; export NR_AGENT_VERSION="newrelic-php5-11.0.0.13-linux.tar.gz"; curl -so - https://download.newrelic.com/php_agent/archive/11.0.0.13/${NR_AGENT_VERSION} | tar zxf - && \
cd newrelic-php* && NR_INSTALL_SILENT=1 NR_INSTALL_USE_CP_NOT_LN=1 ./newrelic-install install && \
rm -rf /tmp/nrinstall* && \
echo 'newrelic.daemon.start_timeout = "5s"' >> /etc/php/${PHP_VERSION}/mods-available/newrelic.ini && \
echo 'newrelic.daemon.app_connect_timeout = "15s"' >> /etc/php/${PHP_VERSION}/mods-available/newrelic.ini && \
echo 'newrelic.logfile = /dev/stderr' >> /etc/php/${PHP_VERSION}/mods-available/newrelic.ini && \
echo 'newrelic.loglevel = warning' >> /etc/php/${PHP_VERSION}/mods-available/newrelic.ini && \
echo 'newrelic.enabled = false' >> /etc/php/${PHP_VERSION}/mods-available/newrelic.ini && \
mkdir -p /var/log/newrelic && \
chown 33:33 /var/log/newrelic && \
chown 33:33 /etc/php/${PHP_VERSION}/mods-available/newrelic.ini && \
rm -f /etc/php/*/*/conf.d/newrelic.ini && \
phpenmod newrelic
# Routine to install Data Dog agent
# https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/php/?tab=containers
# You must set DD_AGENT_HOST and DD_TRACE_AGENT_PORT to point at your DD Agent
# We also clean up whatever this config file layout is
RUN \
curl -LO https://github.com/DataDog/dd-trace-php/releases/download/1.2.0/datadog-setup.php -o /tmp/datadog-setup.php && \
if [[ ${PHP_VERSION} = "5.6" ]] || [[ ${PHP_VERSION} = "7.0" ]]; then php datadog-setup.php --php-bin=all; else php datadog-setup.php --php-bin=all; fi && \
rm -f /tmp/datadog-setup.php && \
mv /etc/php/${PHP_VERSION}/cli/conf.d/98-ddtrace.ini /etc/php/${PHP_VERSION}/mods-available/ddtrace.ini && \
rm -f /etc/php/${PHP_VERSION}/fpm/conf.d/98-ddtrace.ini
RUN \
mkdir -p /run/php-fpm && \
chown 33:33 /run/php-fpm && \
touch /etc/msmtprc && \
chown 33:33 /etc/msmtprc && \
touch /var/log/php${PHP_VERSION}-fpm.log && \
chown 33:33 /var/log/php${PHP_VERSION}-fpm.log && \
ln -s /etc/php/${PHP_VERSION}/fpm/pool.d/ /etc/php-fpm.d
COPY config/php-fpm.conf /etc/php/${PHP_VERSION}/fpm/php-fpm.conf
COPY config/www.conf /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf
COPY config/docker-opcache.ini /etc/php/${PHP_VERSION}/mods-available/docker-opcache.ini
RUN echo "post_max_size = ${UPLOAD_LIMIT}" >> /etc/php/${PHP_VERSION}/mods-available/upload-limits.ini
RUN echo "upload_max_filesize = ${UPLOAD_LIMIT}" >> /etc/php/${PHP_VERSION}/mods-available/upload-limits.ini
RUN echo "catch_workers_output = yes" >> /etc/php-fpm.d/www.conf
RUN chown 33:33 /etc/php-fpm.d/www.conf
RUN \
chown 33:33 /etc/php/${PHP_VERSION}/cli/conf.d && \
chown 33:33 /etc/php/${PHP_VERSION}/fpm/conf.d && \
chown 33:33 /etc/php/${PHP_VERSION}/mods-available
RUN phpdismod opcache && phpenmod docker-opcache upload-limits opcache
RUN ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm
RUN echo 'alias ls="ls --color=auto"' > /etc/profile.d/colorls.sh
COPY entrypoint.sh /entrypoint.sh
RUN ln -s /usr/bin/msmtp /usr/sbin/sendmail && chmod +x /entrypoint.sh
USER www-data
WORKDIR /var/www/html
CMD ["/entrypoint.sh"]