Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added php-fpm_exporter binary and entrypoint script #316

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion images/php/Dockerfile.fpm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ ARG PHP_VERSION=8.3
FROM uselagoon/php-${PHP_VERSION}-fpm:latest

ARG BAY_CLI_VERSION=v1.1.3
ARG PHP_FPM_EXPORTER_VERSION=2.2.0

RUN mkdir /bay
COPY 01-bay.ini /usr/local/etc/php/conf.d/
COPY bay-php-config.sh /bay

# Ensure temp dir exists if required
COPY entrypoints/bay-shared-temp-files-dir-check.sh /lagoon/entrypoints
COPY entrypoints/bay-php-fpm_exporter.sh /lagoon/entrypoints

# Add common drupal config.
COPY redis-unavailable.services.yml /bay
Expand All @@ -26,11 +28,16 @@ RUN apk add --no-cache tzdata \
&& echo $TZ > /etc/timezone

# Install bay-cli.
RUN curl -L "https://github.com/dpc-sdp/bay-cli/releases/download/${BAY_CLI_VERSION}/bay_$(echo ${TARGETPLATFORM:-linux/amd64} | tr '/' '_').tar.gz" --output /tmp/bay_$(echo ${TARGETPLATFORM:-linux/amd64} | tr '/' '_').tar.gz
RUN curl -s -L "https://github.com/dpc-sdp/bay-cli/releases/download/${BAY_CLI_VERSION}/bay_$(echo ${TARGETPLATFORM:-linux/amd64} | tr '/' '_').tar.gz" --output /tmp/bay_$(echo ${TARGETPLATFORM:-linux/amd64} | tr '/' '_').tar.gz
RUN tar -C /tmp -xvf /tmp/bay_$(echo ${TARGETPLATFORM:-linux/amd64} | tr '/' '_').tar.gz
RUN chmod +x /tmp/bay
RUN mv /tmp/bay /bin/bay

# Install php-fpm_exporter
RUN curl -s -L "https://github.com/hipages/php-fpm_exporter/releases/download/v${PHP_FPM_EXPORTER_VERSION}/php-fpm_exporter_${PHP_FPM_EXPORTER_VERSION}_$(echo ${TARGETPLATFORM:-linux/amd64} | tr '/' '_')" --output /bin/php-fpm_exporter
RUN chmod +x /bin/php-fpm_exporter
EXPOSE 9253

ONBUILD ARG BAY_DISABLE_FUNCTIONS=phpinfo,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,system,exec,shell_exec,passthru,phpinfo,show_source,highlight_file,popen,fopen_with_path,dbmopen,dbase_open,filepro,filepro_rowcount,filepro_retrieve,posix_mkfifo
ONBUILD ARG BAY_UPLOAD_LIMIT=100M
ONBUILD ARG BAY_POST_MAX=100M
Expand Down
21 changes: 21 additions & 0 deletions images/php/entrypoints/bay-php-fpm_exporter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env sh
set -euo pipefail

#/ Usage: PHP_FPM_EXPORTER_ENABLED=true ./bay-php-fpm_exporter.sh
#/ Options:
#/ --help: Display this help message
usage() { grep '^#/' "$0" | cut -c4- ; exit 0 ; }
expr "$*" : ".*--help" > /dev/null && usage

echoerr() { printf "%s\n" "$*" >&2 ; }
info() { echoerr "[INFO] $*" ; }
warning() { echoerr "[WARNING] $*" ; }
error() { echoerr "[ERROR] $*" ; }
fatal() { echoerr "[FATAL] $*" ; exit 1 ; }

if [ "${PHP_FPM_EXPORTER_ENABLED:-false}" = "true" ]; then
info starting php-fpm_exporter metrics server
php-fpm_exporter server &
else
info php-fpm_exporter metrics server disabled
fi
Loading