Base docker php-fpm alpine box with extra flexibility
2.6K
The intention here is to instantly be able to:
Source: https://github.com/geekstuff-it/docker-php-fpm-alpine
Builds: https://hub.docker.com/r/geekstuffreal/php-fpm-alpine
Dockerizer app: https://github.com/geekstuff-it/php-fpm-nginx-alpine-dockerizer
Nginx slim base: https://hub.docker.com/r/geekstuffreal/nginx-php-alpine
For the examples here, we will use php 7.4.9. You can use latest, 7.3 and other variants as well.
(see here for list of tags you can choose from)
mkdir super-project
cd super-project
docker run --rm -v $(pwd):/app -it geekstuffreal/php-fpm-alpine:7.4.9 php-init
symfony new --demo --no-git .
php-dockerize
At this point your project is docker ready.
It was configured to use the lastest specific php version and latest specific geekstuffreal/php-fpm-alpine version, matching the php box that you choose to initialize with.
To try it out, first ensure you exit the shell from the init phase above. You should be outside of docker at this point and inside your project folder.
Then simply run docker-compose up and see the result at http://localhost:8080/
You should see 6 different stages, meant to give you 3 possible end results. Those end results are a php-fpm dev build, a php-fpm prod build, and an nginx build. Here's how it's structured:
Examples all assume you are in a terminal in the folder where dockerizer generated files.
# Build
docker build --target nginx -t mycode-nginx .
docker build --target prod -t mycode-php-fpm .
# Run (in separate terminals)
docker run --rm --name mycode-php-fpm mycode-php-fpm
docker run -e PHP_FPM_HOST=mycode-php-fpm --link mycode-php-fpm -p 8080:8080 --rm mycode-nginx
# Open http://localhost:8080/ to view result
# Build
docker build --target dev -t mycode-php-fpm-dev .
# Run
docker run --rm --name mycode-php -v $(pwd):/app mycode-php-fpm-dev
docker run --rm --name mycode-nginx --link mycode-php -v $(pwd)/public:/app/public \
-p 8080:8080 -e PHP_FPM_HOST=mycode-php geekstuffreal/nginx-php-alpine:latest
# Open http://localhost:8080/ to view result
docker exec mycode-php php bin/console about
Dev environment:
docker-compose up --build
Prod test environment:
docker-compose -f docker-compose.prod-test.yml up --build
TIP: If you need to use a different host port than 8080, prepend your docker-compose up with LOCAL_HTTP_PORT=8083
On php 7.4.9, with symfony new --demo --no-git ., php-dockerize and docker-compose -f docker-compose.prod-test.yml up --build:
php-fpm image: 171MB
nginx image: 27.8MB
Content type
Image
Digest
Size
45.2 MB
Last updated
about 6 years ago
docker pull geekstuffreal/php-fpm-alpine