Dockerfile generator

v0.3 2014-11-23 23:44 UTC

This package is not auto-updated.

Last update: 2021-02-15 09:22:02 UTC


This library will help you to generate a Dockerfile programmatically.

include 'vendor/autoload.php';

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 <>');

$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 | php -- --install-dir=/usr/local/bin',
    'mv /usr/local/bin/composer.phar /usr/local/bin/composer',

$layer = new Run($cmds, 'Install packages');

$layer = new Expose(array(80, 443), 'Expose Ports');

$writer = new File('Dockerfile');


Excluding FROM and MAINTAINER instructions, which are passed to the constructor, other ones are passed to the writer in the same order as added to the Dockerfile object.