Sign inSign up

keinos/php8-jit

By keinos

•Updated almost 6 years ago

PHP8 beta3. JIT, PECL, Alpine. Works on ARM v6, v7 and x86_64 arch.

Image
3

10K+

keinos/php8-jit repository overview

⁠PHP8.0 with JIT Enabled on Docker

This is a PHP8-dev (php 8.0.0-beta3) Alpine Docker image with JIT feature enabled built from official source⁠.

docker pull keinos/php8-jit:latest
  • The latest tag image works on: ARM v6l, ARM v7l, ARM64 and x86_64 (AMD/Intel) architectures.
Image Informations and notes

  • Built from the latest master branch from PHP-src⁠ @ GitHub.

    • Date built: See the version badge above.
  • Tags available

    • latest: (Works on ARM v6l, ARM v7l, ARM64, x86_64 (AMD/Intel) architectures)
    • For the other available tags to pull, see⁠.
  • This image is based on:

  • Image Info

  • Path Info

    • Configuration File (php.ini) Path: usr/local/etc/php/conf.d
    • Extension File Path: /usr/local/lib/php/extensions
    • PHP Source Archive: /usr/src/php.zip (To extract run docker-php-source extract)
      • To lighten the image, you may delete this file after all.
    • PHP Source Path (After extraction): /usr/src/php/php-src-master/
  • Settings to be noted:

    • php -i: info-phpinfo.txt⁠
    • php -m: info-get_loaded_extensions.txt⁠
    • Default user: www-data
    • Constant GLOB_BRACE flag for glob is not available.
    • Modules/Extensions:
      • JIT/FFI/OPcache/Sodium/PECL: enabled
    • mbstring: enabled
      • multibyte = On
      • Encoding = UTF-8 (Both script and internal)
      • language = Japanese
    • GD: enabled
    • etc.

⁠Usage

$ # Pull latest image
$ docker pull keinos/php8-jit
...
$ # Run interactively
$ docker run --rm -it keinos/php8-jit
Interactive shell

php > echo phpversion();
8.0.0-dev
php >
php > exit
$
$ # Mount local file and run/execute the script
$ ls
test.php

$ # Run script
$ docker run --rm \
>   -v $(pwd)/test.php:/app/test.php \
>   keinos/php8-jit \
>   php /app/test.php
Hello, World!
$
$ # Mount files and run interactively inside the container
$ docker run --rm -it -v $(pwd):/app keinos/php8-jit /bin/sh
/ $ php -v
PHP 8.0.0-dev (cli) (built: Jun 27 2020 22:23:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0-dev, Copyright (c), by Zend Technologies
/ $ cd /app
/app $
/app $ ls
test.php
/app $ php test.php
Hello, World!
/app $
/app $ exit
$
FROM keinos/php8-jit:latest

USER root

COPY . /app

WORKDIR /app

# Install composer
RUN \
    echo '- Installing composer ...' && \
    EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"; \
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \
    ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"; \
    [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] && { >&2 echo 'ERROR: Invalid installer signature'; exit 1; }; \
    php composer-setup.php --quiet --install-dir=/bin --filename=composer && \
    composer --version && \
    rm composer-setup.php

# Install PHPUnit
RUN \
    composer require --ignore-platform-reqs phpunit/phpunit && \
    ./vendor/bin/phpunit --version

ENTRYPOINT [ "/app/vendor/bin/phpunit", "--testdox", "./tests" ]

⁠Samples

⁠Advanced Usage

⁠Installing Extensions

To instal PHP extensions⁠ use docker-php-ext-install command. (This will enable the extension as well.)

  • Available extensions to install

  • Dockerfile sample to install gettext extension.

    FROM keinos/php8-jit:latest
    
    # You need a root access to install
    USER root
    
    RUN \
        # Install dependencies for gettext
        apk --no-cache add gettext-dev && \
        # Install gettext extension
        docker-php-ext-install gettext
    
    # Switch back to default user
    USER www-data
    
    
⁠Installing PECL Packages

The PECL⁠ command is included. (Since build-20200825⁠, Issue #13⁠)

But as an alternative, you can use docker-php-ext-pecl install to install PECL package from source.

  • Sample of installing YAML Functions⁠ of PECL from source.

    FROM keinos/php8-jit:latest
    
    # You need a root access to compile and install packages
    USER root
    
    RUN \
        # Install dependencies for YAML
        apk --no-cache add yaml-dev && \
        # Install PECL from source
        docker-php-ext-pecl install yaml
    
    # Switch back to default user
    USER www-data
    
  • Note: Some PECL extension packages are not available to install. Mostly the pre-built extensions such as 'json', 'hash' and etc.

⁠Perfomance Comparison

Testv5.6.40v7.0.33v7.1.33v7.2.31v7.3.18v7.4.68.0.0-dev
(JIT Off)
8.0.0-dev
(JIT On)
Fibonacci(32)⁠1.5210.6650.5980.2690.2390.1940.2610.107
Zundoko-Kiyoshi Looping⁠2.4851.4621.4130.7010.6460.6360.6720.416
-- Zend Bench⁠ --
simple0.1780.1000.1010.0640.0510.0410.0540.002
simplecall0.1860.0270.0270.0100.0100.0070.0100.001
simpleucall0.2100.0710.0800.0230.0180.0250.0220.001
simpleudcall0.2260.0760.0880.0280.0210.0210.0240.001
mandel0.4910.3200.3290.1890.1900.1750.1890.007
mandel20.6430.3600.3580.1670.1670.1840.1700.008
ackermann(7)0.1870.0610.0670.0320.0310.0310.0330.015
ary(50000)0.0310.0080.0070.0070.0080.0070.0070.007
ary2(50000)0.0250.0060.0050.0060.0070.0060.0060.006
ary3(2000)0.2980.1420.1240.0590.0470.0440.0490.015
fibo(30)0.5940.2300.2280.1060.0910.0810.0930.042
hash1(50000)0.0490.0240.0240.0160.0150.0150.0150.016
hash2(500)0.0530.0220.0230.0130.0080.0080.0080.011
heapsort(20000)0.1450.0730.0690.0370.0360.0360.0370.014
matrix(20)0.1300.0670.0620.0340.0350.0300.0300.014
nestedloop(12)0.3010.1450.1430.0880.0910.0720.0910.013
sieve(30)0.1510.0410.0530.0210.0180.0140.0170.005
strcat(200000)0.0270.0140.0150.0110.0110.0110.0100.010
------------------------------------------------------------------
Total3.9231.7871.8040.9110.8550.8050.8670.187
  • Tested Env

    $ # macOS Mojave (OSX 10.14.5)
    $ sw_vers
    ProductName:	Mac OS X
    ProductVersion:	10.14.6
    BuildVersion:	18G4032
    
    $ # Docker 19.03.8
    $ docker version
    Client: Docker Engine - Community
    Version:           19.03.8
    API version:       1.40
    Go version:        go1.12.17
    Git commit:        afacb8b
    Built:             Wed Mar 11 01:21:11 2020
    OS/Arch:           darwin/amd64
    Experimental:      true
    
    Server: Docker Engine - Community
    Engine:
      Version:          19.03.8
      API version:      1.40 (minimum version 1.12)
      Go version:       go1.12.17
      Git commit:       afacb8b
      Built:            Wed Mar 11 01:29:16 2020
      OS/Arch:          linux/amd64
      Experimental:     true
    containerd:
      Version:          v1.2.13
      GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
    runc:
      Version:          1.0.0-rc10
      GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
    docker-init:
      Version:          0.18.0
      GitCommit:        fec3683
    
    

Tag summary

Content type

Image

Digest

Size

21.3 MB

Last updated

almost 6 years ago

docker pull keinos/php8-jit