smalot / dockerfile
Dockerfile generator
v0.3
2014-11-23 23:44 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-11-19 04:32:48 UTC
README
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 <smalot@actualys.com>'); $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);
Notes
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.