Docker setup for a Laravel project with Apache and PHP.
- PHP version specified in the
Dockerfile. - MariaDB
- phpMyAdmin is available at
http://localhost:8080. - NodeJS and NPM are installed.
- Laravel CLI is available.
- Claude CLI is available for AI interactions.
- Selenium is available for e2e testing with Laravel Dusk.
- Configuration through .env file:
- Project prefix for the Docker container
- NodeJS version
- XDebug
- Document root
Rename the .env.example file to .env and adjust the environment variables as needed.
Start the Docker container with the following command:
docker-compose up --buildStop the Docker container with:
docker-compose downOpen a terminal inside the Docker container (my-laravel-project is the project prefix defined in the .env file):
docker exec -u developer -it my-laravel-project-php-apache /bin/bashFor the Docker port forwarding to work when running composer run dev, you need to do some changes to composer.json and vite config:
- In composer.json, add
--host=0.0.0.0 --port=8000to thedevscript. - In vite.config.js, extend the server configuration:
server: {
+ host: '0.0.0.0',
+ port: 5173,
+ strictPort: true,
+ hmr: {
+ host: 'localhost',
+ },
watch: {
+ usePolling: true,
ignored: ['**/storage/framework/views/**'],
},
},