-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add docs for custom docker image * docs: improve Docker documentation * more docs Co-authored-by: Kévin Dunglas <[email protected]>
- Loading branch information
1 parent
9ef3bd7
commit 3641552
Showing
3 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,32 @@ The server is listening on `127.0.0.1:8080`: | |
|
||
curl -v http://127.0.0.1:8080/phpinfo.php | ||
|
||
# Building Docker Images Locally | ||
|
||
Print bake plan: | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --print | ||
``` | ||
|
||
Build FrankenPHP images for amd64 locally: | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/amd64" | ||
``` | ||
|
||
Build FrankenPHP images for arm64 locally: | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/arm64" | ||
``` | ||
|
||
Build FrankenPHP images from scratch for arm64 & amd64 and push to Docker Hub: | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --pull --no-cache --push | ||
``` | ||
|
||
## Misc Dev Resources | ||
|
||
* [PHP embedding in uWSGI](https://github.com/unbit/uwsgi/blob/master/plugins/php/php_plugin.c) | ||
|
@@ -63,3 +89,8 @@ The server is listening on `127.0.0.1:8080`: | |
* [What the heck is TSRMLS_CC, anyway?](http://blog.golemon.com/2006/06/what-heck-is-tsrmlscc-anyway.html) | ||
* [PHP embedding on Mac](https://gist.github.com/jonnywang/61427ffc0e8dde74fff40f479d147db4) | ||
* [SDL bindings](https://pkg.go.dev/github.com/veandco/[email protected]/sdl#Main) | ||
|
||
## Docker-Related Resources | ||
|
||
* [Bake file definition](https://docs.docker.com/build/customize/bake/file-definition/) | ||
* [docker buildx build](https://docs.docker.com/engine/reference/commandline/buildx_build/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,80 @@ | ||
# Building Docker Images | ||
# Building Custom Docker Image | ||
|
||
Print bake plan: | ||
[FrankenPHP Docker images](https://hub.docker.com/repository/docker/dunglas/frankenphp) are based on [official PHP images](https://hub.docker.com/_/php/). Alpine Linux and Debian variants are provided for popular architectures. | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --print | ||
## How to Use The Images | ||
|
||
Create a `Dockerfile` in your project: | ||
|
||
```Dockerfile | ||
FROM dunglas/frankenphp | ||
|
||
COPY . /app/public | ||
``` | ||
|
||
Build FrankenPHP images for amd64 locally: | ||
Then, run the commands to build and run the Docker image: | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/amd64" | ||
$ docker build -t my-php-app . | ||
$ docker run -it --rm --name my-running-app my-php-app | ||
``` | ||
|
||
Build FrankenPHP images for arm64 locally: | ||
## How to Install More PHP Extensions | ||
|
||
The [`docker-php-extension-installer`](https://github.com/mlocati/docker-php-extension-installer) script is provided in the base image. | ||
Adding additional PHP extensions is straightforwardd: | ||
|
||
```dockerfile | ||
FROM dunglas/frankenphp | ||
|
||
# add additional extensions here: | ||
RUN install-php-extensions \ | ||
pdo_mysql \ | ||
gd \ | ||
intl \ | ||
zip \ | ||
opcache | ||
|
||
# ... | ||
``` | ||
docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/arm64" | ||
|
||
# Enabling the Worker Mode by Default | ||
|
||
Set the `FRANKENPHP_CONFIG` environment variable to start FrankenPHP with a worker script: | ||
|
||
```Dockerfile | ||
FROM dunglas/frankenphp | ||
|
||
# ... | ||
|
||
ENV FRANKENPHP_CONFIG="worker ./public/index.php" | ||
``` | ||
|
||
Build FrankenPHP images from scratch for arm64 & amd64 and push to Docker Hub: | ||
# Using a Volume in Development | ||
|
||
To develop easily with FrankenPHP, mount the directory from your host containing the source code of the app as a volume in the Docker container: | ||
|
||
``` | ||
docker buildx bake -f docker-bake.hcl --pull --no-cache --push | ||
docker run -v $PWD:/app/public -p 80:80 -p 443:443 my-php-app | ||
``` | ||
|
||
## Resources | ||
With Docker Compose: | ||
|
||
* [Bake file definition](https://docs.docker.com/build/customize/bake/file-definition/) | ||
* [docker buildx build](https://docs.docker.com/engine/reference/commandline/buildx_build/) | ||
```yaml | ||
# docker-compose.yml | ||
|
||
version: '3.1' | ||
|
||
services: | ||
|
||
php: | ||
image: dunglas/frankenphp | ||
# uncomment the following line if you want to use a custom Dockerfile | ||
#build: . | ||
restart: always | ||
ports: | ||
- 80:80 | ||
- 443:443 | ||
volumes: | ||
- ./:/app/public | ||
``` |