This is a working demo for the blog post on getting started with FrankenPHP and Laravel.
The purpose is to demonstrate how you can use FrankenPHP to run a Laravel application in a Docker container that can be used for both development and production.
Note
The env.example
file is altered to match the local environment for this demo. It is not suitable for use in production.
- Clone the repository
- Run
composer install
- Copy
.env.example
to.env
- Run
php artisan key:generate
- Run
docker compose build --no-cache
- Run
docker compose up -d
- Run
docker compose run --rm artisan migrate
You should now be able to access the application at http://localhost
To build a production-ready, you need to install dependencies correctly and optimize the application for production:
composer install --no-dev --prefer-dist --optimize-autoloader
php artisan optimize
Next, you can build your production image, by targeting the production
target in the Dockerfile
:
docker build -t laravel-app --target production .
You can use this image to run the application in a production environment of your choice.
When you're done with the application, you can run docker compose down -v
to clean up the containers and volumes.