Code Monkey home page Code Monkey logo

docker-xhgui's Introduction

Xhgui docker image

Build Status Docker Pulls

Docker Hub: https://hub.docker.com/r/edyan/xhgui

Docker containers that runs xhgui (which needs mongodb and PHP).

It's based on :

  • edyan/php:5.6 image (jessie stable).
  • or edyan/php:7.2 image (Ubuntu 18.04).
  • or edyan/php:7.4 image (Ubuntu 20.04). Use that one as a preview version, xhgui is not officially compatible with PHP > 7.3

It's made for development purposes. You need to find the right version for your project. Use 5.6 for PHP 5.6 projects and 7.2 / 7.4 for PHP 7.x projects. Just make sure you have the mongodb extension enabled on your main PHP container.

To use it in an integrated environment, try Stakkr

Example

To make it work, you need to link it to an existing PHP environment. Example via docker-compose.yml :

The Docker Compose configuration is different for Compose versions 2 and 3:

version: '2'
services:
  xhgui:
    image: edyan/xhgui:php7.2
    # I need to access xhgui
    ports:
      - "9000:80"
  php:
    hostname: php
    command: /usr/bin/php -S 0.0.0.0:80 -t /var/www
    image: edyan/php:7.2 # That image contains mongodb extension from PECL
    # To have xhgui sources mount xhgui's volumes
    volumes_from: [xhgui]
    ports:
      - "8000:80"
    volumes:
      - "./src:/var/www"

The volumes_from is no longer supported in the Docker Compose version 3 syntax. We have to define a volume for xhgui in the global section of the config file and reference it in each of the services:

version: '3'

volumes:
  xhgui:

services:
  xhgui:
    image: edyan/xhgui:php7.2
    # I need to access xhgui
    ports:
      - "9000:80"
    volumes:
      - xhgui:/usr/local/src
  php:
    hostname: php
    command: /usr/bin/php -S 0.0.0.0:80 -t /var/www
    image: edyan/php:7.2 # That image contains mongodb extension from PECL
    # To have the new mounted volumes as well as the default volumes of xhgui (its source code)
    ports:
      - "8000:80"
    volumes:
      - ./src:/var/www
      - xhgui:/usr/local/src

You need to set an environment variable to define the right mongodb server and then include the prepared profiler to your file, for example src/index.php:

<?php

// Call the profiler
putenv('XHGUI_MONGO_HOST=mongodb://xhgui:27017');
require_once('/usr/local/src/xhgui/external/header.php');

// Run your code
function test_xhgui()
{
    $data = [];
    for ($i = 0; $i < 5000; $i++) {
        $data[] = $i * $i;
        sort($data);
    }
}

test_xhgui();

Finally, launch the environment with : docker-compose up --force-recreate. Then call http://localhost:8000/index.php in your browser and get reports from http://localhost:9000.

Environment variables

  • XHGUI_MONGO_HOST default to mongodb://127.0.0.1:27017, used in XHGui config file.
  • MONGO_PORT default to 27017
  • PHP_WEBSERVER_PORT default to 80

Quick Test

A docker-compose file is available to do some tests:

$ mkdir src
$ echo '<?php putenv("XHGUI_MONGO_HOST=mongodb://xhgui"); require_once("/usr/local/src/xhgui/external/header.php"); $a=[]; for($i=0; $i<10000; $i++){ $a[]=$i; } sort($a); echo "Done";' > src/index.php
$ docker-compose -f docker-compose.sample.yml up --force-recreate -d

Now open http://localhost:8000/index.php to read the new file created. Then http://localhost:9000 to see the report.

Clean :

$ docker-compose -f docker-compose.sample.yml down

docker-xhgui's People

Contributors

edyan avatar jmartin82 avatar mjaschen avatar ngyuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker-xhgui's Issues

Release edyan/xhgui:php7.4 image

Can you please push edyan/xhgui:php7.4 image? It is documented but seems it was not pushed to docker hub?

docker pull edyan/xhgui:php7.4
Error response from daemon: manifest for edyan/xhgui:php7.4 not found: manifest unknown: manifest unknown

Php5.6 : xhgui - Server at xhgui:27017 reports wire version 0, but this version of libmongoc requires at least 3 (MongoDB 3.0)

After having successfully tested the Php7.2 version on a project, I've tried the Php5.6 on another project without success.

I'm using base image vixns/php-nginx:5.6-memcached (Debian Jessie) with the following Dockerfile (excerpt) :

RUN \
  pecl install xhprof-beta; \
  docker-php-ext-enable xhprof; \
  echo "extension=xhprof.so" > /usr/local/etc/php/conf.d/xhprof.ini

RUN \
  apt-get update && \
  apt-get install -t jessie-backports -y \
    build-essential pkg-config libssl-dev

RUN \
  pecl channel-update pecl.php.net && \
  pecl install -f mongodb && \
  rm -Rf /tmp/pear && \
  # Enable module mongodb
  echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongodb.ini && \
  docker-php-ext-enable mongodb

RUN \
  apt-get purge build-essential pkg-config libssl-dev -y && \
  apt-get autoremove -y && \
  apt-get autoclean && \
  apt-get clean

I've been trying different versions of the https://pecl.php.net/package/mongodb package, with no luck. Any idea what could be causing this error ?

Server at xhgui:27017 reports wire version 0, but this version of libmongoc requires at least 3 (MongoDB 3.0)

Use docker COPY directice

you can replace this:

# Clone xhgui and install master as there is no suitable tag, then remove useless files
RUN     git clone -b 0.13.0 --depth 1 https://github.com/perftools/xhgui /usr/local/src/xhgui && \
        cd /usr/local/src/xhgui && \
        rm -rf /usr/local/src/xhgui/.git \
               /usr/local/src/xhgui/.scrutinizer.yml \
               /usr/local/src/xhgui/.travis.yml \
               /usr/local/src/xhgui/phpunit.xml \
               /usr/local/src/xhgui/README.md \
               /usr/local/src/xhgui/tests

with:

COPY --from=xhgui/xhgui:0.13.0 /var/www/xhgui /usr/local/src/xhgui

what does it mean "no suitable tag"? have you reported your issue to xhgui issue tracker?

No mongodb connection / incorrect ip binding?

Hello,
I've tried to use this container with the following docker-compose setup:

version: '2'
services:
  xhgui:
    image: edyan/xhgui
  api:
    hostname: api
    build: 
      context: .
      dockerfile: ./docker/php-7/Dockerfile
    ports:
      - "80:80"
    links:
    - xhgui
    volumes_from: [xhgui]
    volumes:
      - ./xhgui-config.php:/usr/local/src/xhgui/config/config.php
      - ./src:/var/www/html/
      - ./docker/vhosts/:/etc/apache2/sites-enabled/

But when opening xhgui, I get the error that it can't connect to mongodb (mongodb://xhgui). The host "xhgui" is reachable inside the docker network and I've found out that the problem is mongodbs bind_ip setting. It's set to localhost by default. How is this supposed to work?

I've started it via mongod --bind_ip=0.0.0.0 and it worked. Is this setup only for the usage with Stakkr or do i use it the wrong way? :)

fpm and nginx config files will be empty at startup

Hi.

When input and output redirect to same file, contents of file will be empty.

https://github.com/edyan/docker-xhgui/blob/master/php7.2/entrypoint.sh#L2-L3

envsubst '${NGINX_PORT},${MONGO_PORT},${PHPFPM_PORT}' < /etc/nginx/sites-available/default > /etc/nginx/sites-available/default
envsubst '${PHPFPM_PORT}' < /etc/php/7.2/fpm/pool.d/www.conf > /etc/php/7.2/fpm/pool.d/www.conf 

Maybe, you can be fixes as follows.

Dockerfile

COPY conf/nginx.default.conf /etc/nginx/sites-available/default.template
COPY conf/www.conf /etc/php5/fpm/pool.d/www.conf.template

entrypoint.sh

envsubst '${NGINX_PORT},${MONGO_PORT},${PHPFPM_PORT}' < /etc/nginx/sites-available/default.template > /etc/nginx/sites-available/default
envsubst '${PHPFPM_PORT}' < /etc/php/7.2/fpm/pool.d/www.conf.template > /etc/php/7.2/fpm/pool.d/www.conf

docker-xhgui from Apr 17 2018 stopped working due to change of underlying: `edyan/php:7.2` image

First I've wanted to thank you for this amazing piece of work.
I've thought I will just let you know that this stopped working to me (Mongodb doesn't start) as a result of backward incompatible change to the edyan/php:7.2 image.

I've resolved my problem, however just wanted to let you know so you're aware.

Background:
I've had this version of docker-xhgui checkout out on my machine: 5911eb7#diff-30bcd298f2d1a9f97b0d024c3353d570
It was working fine, until I pruned the docker caches and rebuilt the php7.2, docker-xhgui.
When I've rebuilt it, it had to pick newer version of: edyan/php:7.2 which actually doesn't work with the older version of docker-xhgui.
I've built edyan/php:7.2 docker image on my own from:
edyan/php-fpm@c55c685#diff-74c5d9234051010a38a669f48bfeb435
and it all started to work again.

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.