PHP code example of smalot / dockerfile

1. Go to this page and download the library: Download smalot/dockerfile library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

smalot / dockerfile example snippets




use \Smalot\Docker\Dockerfile\Dockerfile;
use \Smalot\Docker\Dockerfile\Instruction\Run;
use \Smalot\Docker\Dockerfile\Instruction\Expose;
use \Smalot\Docker\Dockerfile\Source\File;

$dockerFile = new Dockerfile('debian:wheezy', 'Sebastien MALOT <[email protected]>');

$cmds = array(
    'apt-get update',
    'DEBIAN_FRONTEND=noninteractive apt-get -y upgrade',
    'DEBIAN_FRONTEND=noninteractive apt-get -y install supervisor pwgen',
    'DEBIAN_FRONTEND=noninteractive apt-get -y install git apache2 libapache2-mod-php5 php5-mysql php5-pgsql php5-gd php-pear php-apc curl',
    'curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin',
    'mv /usr/local/bin/composer.phar /usr/local/bin/composer',
);

$layer = new Run($cmds, 'Install packages');
$dockerFile->addLayer($layer);

$layer = new Expose(array(80, 443), 'Expose Ports');
$dockerFile->addLayer($layer);

$writer = new File('Dockerfile');
$dockerFile->write($writer);