Minimal PHP web docker container
395
A proof-of-concept project demonstrating how to create extremely small Docker images using statically compiled PHP binaries. All images are built from scratch, resulting in minimal footprint containers.
This project uses static-php-cliā to build standalone PHP binaries and packages them into minimal Docker images. Three different runtime configurations are included:
scratchThe easiest way to try these images is to pull them directly from Docker Hub:
docker pull crazygoat/tinyphp:php-server
docker pull crazygoat/tinyphp:webman
docker pull crazygoat/tinyphp:symfony
Then run any of them:
docker run -p 8080:8080 crazygoat/tinyphp:php-server
To build all runtimes and Docker images from source:
./build.sh
This script will:
spc)craft.yml configurationscrazygoat/tinyphp:php-server)Basic PHP CLI runtime with built-in web server.
docker run -p 8080:8080 crazygoat/tinyphp:php-server
Configuration: runtimes/php-server/craft.yml
crazygoat/tinyphp:webman)Webmanā framework packaged as a single executable using micro.sfx.
docker run -p 8080:8080 crazygoat/tinyphp:webman
crazygoat/tinyphp:symfony)Symfony application with Workermanā runtime bundle.
docker run -p 8080:8080 crazygoat/tinyphp:symfony
.
āāā build.sh # Main build script
āāā spc # Static PHP CLI binary (downloaded)
āāā runtimes/
ā āāā php-server/ # PHP built-in server runtime
ā āāā webman/ # Webman framework runtime
ā āāā workerman_sf/ # Symfony + Workerman runtime
āāā buildroot/ # Build artifacts
āāā downloads/ # Downloaded dependencies
āāā pkgroot/ # Package root directory
All images are tagged under crazygoat/tinyphp:
crazygoat/tinyphp:latest ā php-servercrazygoat/tinyphp:php-server ā PHP built-in servercrazygoat/tinyphp:webman ā Webman frameworkcrazygoat/tinyphp:symfony ā Symfony + WorkermanThe project uses static-php-cli (spc) to compile PHP and its extensions into a single static binary. Each runtime has a craft.yml file that defines:
These binaries are then copied into FROM scratch Docker images, resulting in containers that contain only the essential files needed to run.
This is a proof-of-concept project. Check individual runtime directories for their respective licenses.
Content type
Image
Digest
sha256:5bfa486b0ā¦
Size
1.8 MB
Last updated
12 months ago
docker pull crazygoat/tinyphp