PHP code example of axy / docker-dockerfile-builder
1. Go to this page and download the library: Download axy/docker-dockerfile-builder 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/ */
axy / docker-dockerfile-builder example snippets
use axy\docker\dockerfile\builder\DockerfilePHPBuilder;
$builder = new DockerfilePHPBuilder('8.0', 'fpm', false);
$builder->labels['author'] = 'Me';
$builder->env['var'] = 'value';
$builder->user = '1000:1000';
$builder->cmd = 'php -m';
$builder->workdir('/var/www/app');
$builder->copy('file.php', 'index.php', '1000:1000');
$builder->packages(['curl', 'libpng-dev', 'libonig-dev', 'zip'], 'Install CURL etc');
$builder->extensions = ['bcmath', 'mbstring', 'pdo_mysql'];
$builder->pecl = ['xdebug'];
$builder->ini['error_reporting'] = 'E_ALL';
$builder->ini['post_max_size'] = '128M';
echo $builder->build();
FROM php:8.0-fpm
LABEL author="Me"
ENV var=value
WORKDIR /var/www/app
COPY --chown=1000:1000 file.php index.php
# Install CURL etc
RUN apt-get update && apt-get install -y \
curl \
libpng-dev \
libonig-dev \
zip
RUN docker-php-ext-install \
bcmath \
mbstring \
pdo_mysql \
&& pecl install \
xdebug \
&& docker-php-ext-enable \
xdebug \
&& echo "error_reporting=E_ALL" >> /usr/local/etc/php/conf.d/docker.ini \
&& echo "post_max_size=128M" >> /usr/local/etc/php/conf.d/docker.ini \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN rm -rf /var/lib/apt/lists/*
CMD php -m
USER 1000:1000