Skip to main content

Google Cloud App Engine

Custom Docker

To install the PHP monitoring agent in the Google Cloud App engine, the custom docker must be used.

Defaults of Google App Engine PHP cannot run PHP extension modules and service daemons. Install them via Docker Container.

In the app.yaml file (Google App engine's configuration file), configure the settings with the flex environment and custom run-time.

$ vi app.yaml
env: flex
runtime: custom

To run with the custom Docker, create Dockerfile in the same location as app.yaml set with the flex environment and the custom run-time. See the default PHP Docker image for the Google App engine.

# google-appengine php php56, php70, php71
FROM gcr.io/google-appengine/php56

Installation of the PHP monitoring agent

Install the PHP monitoring agent.

  1. Install the library (wget).

    RUN apt-get install wget -y
  2. Create the php-fpm execution command link.

    RUN ln -s /opt/php/sbin/php-fpm /usr/bin/php-fpm
  3. Install the WhaTap repository and whatap-php package.

    RUN wget http://repo.whatap.io/debian/release.gpg -O -| apt-key add -
    RUN wget http://repo.whatap.io/debian/whatap-repo_1.0_all.deb
    RUN dpkg -i whatap-repo_1.0_all.deb
    RUN apt-get update
    RUN apt-get install whatap-php
  4. Configure the PHP extension module and whatap-php service.

    #RUN (echo "[granted access key]"; echo "[granted server IP ]")|/usr/whatap/php/install.sh
    RUN (echo "xxxxxxxx"; echo "1.1.1.1/2.2.2.2")|/usr/whatap/php/install.sh
    Note

    After creating a PHP monitoring project, the access key and server IP is issued. With the delimiter (/), multiple IPs can be issued.

  5. Run the whatap-php service through supervisor.

    RUN echo "[program:whatap-php]" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "command = /etc/init.d/whatap-php start" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "stdout_logfile = /dev/stdout" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "stdout_logfile_maxbytes=0" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "stderr_logfile = /dev/stderr" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "stderr_logfile_maxbytes=0" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "user = root" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "autostart = true" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "autorestart = true" >> /etc/supervisor/conf.d/whatap.conf
    RUN echo "priority = 10" >> /etc/supervisor/conf.d/whatap.conf

Adding firewall rules

Add firewall rules for the network that is used by the Google App engine. TCP transmission must be allowed through the port 6600 for the issued server IP.

Checking the deployment and instance

Deploy app.yaml and Dockerfile that have been set through the Google Cloud SDK.

$ gcloud app deploy

Check the App engine instance generated in the Google Cloud Console.