Skip to content

Repox/laravel-frankenphp-docker

Repository files navigation

Demo Project

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.

Requirements

Getting Started

  1. Clone the repository
  2. Run composer install
  3. Copy .env.example to .env
  4. Run php artisan key:generate
  5. Run docker compose build --no-cache
  6. Run docker compose up -d
  7. Run docker compose run --rm artisan migrate

You should now be able to access the application at http://localhost

Production build

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.

Cleaning up

When you're done with the application, you can run docker compose down -v to clean up the containers and volumes.

About

Getting started with Laravel, FrankenPHP and MySQL

Resources

Stars

Watchers

Forks

Languages