diff --git a/assets/fpm-apache/conf/vhost.conf b/assets/fpm-apache/conf/vhost.conf index f2236dc..fd7ca88 100644 --- a/assets/fpm-apache/conf/vhost.conf +++ b/assets/fpm-apache/conf/vhost.conf @@ -19,7 +19,7 @@ DocumentRoot "/var/www/localhost/htdocs" # Options Indexes FollowSymLinks - DirectoryIndex index.php index.html + DirectoryIndex index.html # # AllowOverride controls what directives may be placed in .htaccess files. diff --git a/assets/index.html b/assets/index.html new file mode 100644 index 0000000..d3df80d --- /dev/null +++ b/assets/index.html @@ -0,0 +1,562 @@ + + + + + + ByJG PHP Docker Image + + + +
+
+

ðŸģ ByJG PHP Docker Image

+

Lightweight, Production-Ready PHP Containers

+
+ Alpine Linux + 45+ Extensions + Multi-Architecture +
+
+ +
+
+

âœĻ Key Features

+
+
+

ðŸŠķ Lightweight

+

Based on Alpine Linux with optimized image sizes ranging from 135-154MB uncompressed.

+
+
+

🚀 Production Ready

+

Optimized for both development and production environments with security best practices.

+
+
+

🔧 45+ Extensions

+

Pre-installed with all essential PHP extensions including database drivers, image processing, and caching.

+
+
+

ðŸŽŊ Multiple Variants

+

Choose from base, CLI, FPM, FPM-Nginx, or FPM-Apache configurations.

+
+
+

🌍 Multi-Architecture

+

Native support for amd64 (x86_64) and arm64 (Raspberry Pi, AWS Graviton).

+
+
+

🛠ïļ Developer Tools

+

CLI images include Composer, PHPUnit, PHP_CodeSniffer, and PHPMD.

+
+
+
+ +
+

ðŸ“Ķ Pre-installed PHP Extensions

+

All images come with 45+ PHP extensions ready to use:

+
+
bcmath
+
ctype
+
curl
+
dba
+
dom
+
exif
+
fileinfo
+
filter
+
ftp
+
gd
+
gettext
+
iconv
+
igbinary
+
imagick
+
intl
+
json
+
mbstring
+
mcrypt
+
memcached
+
mongodb
+
mysqli
+
mysqlnd
+
opcache
+
openssl
+
pcntl
+
pdo
+
pdo_dblib
+
pdo_mysql
+
pdo_pgsql
+
pdo_sqlite
+
phar
+
posix
+
redis
+
session
+
shmop
+
simplexml
+
soap
+
sockets
+
sqlite3
+
tokenizer
+
xdebug
+
xml
+
xmlreader
+
xmlwriter
+
xsl
+
yaml
+
zip
+
zlib
+
+
+ +
+

🔧 Environment Variables Configuration

+

Configure your container without modifying configuration files:

+ +
+

PHP_CONTROLLER

+

Description: Enable single-file controller pattern. All requests route to the specified PHP file.

+

Default: Not set

+

Use Case: Perfect for Symfony, Laravel, Slim frameworks

+ docker run -e PHP_CONTROLLER=/index.php @@DOCKER_IMAGE@@ +
+ +
+

NGINX_ROOT

+

Description: Set the web server document root

+

Default: /var/www/html

+ docker run -e NGINX_ROOT=/srv/public @@DOCKER_IMAGE@@ +
+ +
+

NGINX_SSL_CERT & NGINX_SSL_CERT_KEY

+

Description: Enable HTTPS by providing paths to SSL certificate and key files

+

Default: Not set (HTTP only)

+ docker run -v /etc/ssl:/etc/ssl \ + -e NGINX_SSL_CERT=/etc/ssl/my.cert \ + -e NGINX_SSL_CERT_KEY=/etc/ssl/my.key \ + @@DOCKER_IMAGE@@ +
+ +
+

PHP_FPM_SERVER

+

Description: Configure the FastCGI server address for PHP-FPM

+

Default: 127.0.0.1:9000

+ docker run -e PHP_FPM_SERVER=127.0.0.1:9000 @@DOCKER_IMAGE@@ +
+ +
+

DISABLEMODULE_[name]

+

Description: Disable specific PHP modules at runtime to optimize performance

+

Default: All modules enabled

+ docker run -e DISABLEMODULE_DOM=true -e DISABLEMODULE_XSL=true @@DOCKER_IMAGE@@ +
+ +
+

VERBOSE

+

Description: Enable verbose logging for troubleshooting startup and configuration

+

Default: Not set

+ docker run -e VERBOSE=true @@DOCKER_IMAGE@@ +
+
+ +
+

📊 Image Information

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyValue
Docker Image@@DOCKER_IMAGE@@
PHP Version@@PHP_VERSION@@
PHP Variant@@PHP_VARIANT@@
Build Date@@BUILD_DATE@@
Base OSAlpine Linux
Supported Architecturesamd64, arm64
XDebug Port9001
+
+ +
+

ðŸŽŊ Quick Start Examples

+ +

Development Environment

+
+
+

ðŸ”đ Using docker run

+ docker run -d \ + -v $PWD:/var/www/html \ + -p 80:80 \ + @@DOCKER_IMAGE@@ +
+
+

ðŸ”đ Using Dockerfile

+ FROM @@DOCKER_IMAGE@@ + +COPY . /var/www/html + +EXPOSE 80 +
+
+ +

With Framework (Laravel, Symfony, PHP Rest Reference)

+
+
+

ðŸ”đ Using docker run

+ docker run -d \ + -e PHP_CONTROLLER="/index.php" \ + -e NGINX_ROOT="/srv/public" \ + -v $PWD:/svr \ + -w /svr \ + -p 80:80 \ + @@DOCKER_IMAGE@@ +
+
+

ðŸ”đ Using Dockerfile

+ FROM @@DOCKER_IMAGE@@ + +ENV PHP_CONTROLLER="/index.php" +ENV NGINX_ROOT="/svr/public" +WORKDIR /svr + +COPY . /svr + +EXPOSE 80 +
+
+ +

Production with SSL

+
+
+

ðŸ”đ Using docker run

+ docker run -d \ + -e NGINX_SSL_CERT=/etc/ssl/cert.pem \ + -e NGINX_SSL_CERT_KEY=/etc/ssl/key.pem \ + -v /path/to/certs:/etc/ssl \ + -v $PWD:/var/www/html \ + -p 443:443 \ + @@DOCKER_IMAGE@@ +
+
+

ðŸ”đ Using Dockerfile

+ FROM @@DOCKER_IMAGE@@ + +ENV NGINX_SSL_CERT=/etc/ssl/cert.pem +ENV NGINX_SSL_CERT_KEY=/etc/ssl/key.pem + +COPY certs/ /etc/ssl/ +COPY . /var/www/html + +EXPOSE 443 +
+
+
+ +
+

🔍 Explore More

+

View detailed PHP configuration and loaded extensions

+ View PHP Info + Full Documentation + GitHub Repository +
+
+ + +
+ + diff --git a/generator/__init__.py b/generator/__init__.py index c78cb7c..afd3523 100644 --- a/generator/__init__.py +++ b/generator/__init__.py @@ -134,7 +134,16 @@ def build_fpm_apache(self): self.dockerfile_content["copy"] += "COPY assets/fpm-apache/conf/vhost.conf /etc/apache2/conf.d/\n" self.dockerfile_content["copy"] += "COPY assets/fpm-apache/conf/supervisord.conf /etc/supervisord.conf\n" self.dockerfile_content["copy"] += "COPY assets/script/exit-event-listener.py /exit-event-listener.py\n" - return self._build() + self.dockerfile_content["copy"] += "COPY assets/index.html /tmp/index.html\n" + image = self._build() + # Process index.html with build-time variables + self.dockerfile_content["run"] += "RUN sed -i " + \ + f"-e 's|@@DOCKER_IMAGE@@|{image}|g' " + \ + f"-e 's|@@PHP_VERSION@@|{self.build_config['version']['major']}.{self.build_config['version']['minor']}|g' " + \ + f"-e 's|@@PHP_VARIANT@@|php{self.build_config['version']['suffix']}|g' " + \ + f"-e 's|@@BUILD_DATE@@|{self.build_date}|g' " + \ + "/var/www/localhost/htdocs/index.html\n" + return image def build_fpm_nginx(self): self._banner("fpm-nginx") @@ -145,8 +154,16 @@ def build_fpm_nginx(self): self.dockerfile_content["copy"] += "COPY assets/fpm-nginx/conf/supervisord.conf /etc/supervisord.conf\n" self.dockerfile_content["copy"] += "COPY assets/script/exit-event-listener.py /exit-event-listener.py\n" self.dockerfile_content["copy"] += "COPY assets/script/start-nginx.sh /start-nginx.sh\n" - self.dockerfile_content["run"] += "RUN " + self.parse_config("php-fpm-nginx.j2") + "\n" - return self._build() + self.dockerfile_content["copy"] += "COPY assets/index.html /var/www/html/index.html\n" + image = self._build() + # Process index.html with build-time variables + self.dockerfile_content["run"] += "RUN sed -i " + \ + f"-e 's|@@DOCKER_IMAGE@@|{image}|g' " + \ + f"-e 's|@@PHP_VERSION@@|{self.build_config['version']['major']}.{self.build_config['version']['minor']}|g' " + \ + f"-e 's|@@PHP_VARIANT@@|php{self.build_config['version']['suffix']}|g' " + \ + f"-e 's|@@BUILD_DATE@@|{self.build_date}|g' " + \ + "/var/www/html/index.html\n" + return image def build_nginx(self): self._banner("nginx") @@ -159,4 +176,5 @@ def build_nginx(self): self.dockerfile_content["copy"] += "COPY assets/fpm-nginx/conf/nginx.vh.default.conf /etc/nginx/http.d/default.conf\n" self.dockerfile_content["copy"] += "COPY assets/script/start-nginx.sh /start-nginx.sh\n" self.dockerfile_content["copy"] += "COPY assets/entrypoint.sh /\n" + self.dockerfile_content["copy"] += "COPY assets/index.html /tmp/index.html\n" return self._build() diff --git a/requirements.txt b/requirements.txt index 690a2b4..91f3925 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ -Jinja2==3.1.4 +Jinja2==3.1.6 jinja2-cli==0.8.2 -MarkupSafe==2.1.5 -argparse==1.4.0 -PyYAML==6.0.1 \ No newline at end of file +MarkupSafe==3.0.3 +PyYAML==6.0.3 \ No newline at end of file diff --git a/templates/php-fpm-apache.j2 b/templates/php-fpm-apache.j2 index 6f92dbb..aa7079f 100644 --- a/templates/php-fpm-apache.j2 +++ b/templates/php-fpm-apache.j2 @@ -5,5 +5,6 @@ mkdir -p /run/apache2 chmod a+x /start-fpm.sh (ln -s /usr/bin/python3 /usr/bin/python || true) echo "" >> /var/www/localhost/htdocs/info.php +mv /tmp/index.html /var/www/localhost/htdocs/index.html date > /etc/build-date