This is a scaffolding for developing Laravel applications with Docker
- Laravel 7
- bitnami/bitnami-docker-laravel
- (optional) laravel-ui ^2.1 with VueJS and authentication scaffolds
- Install Docker Desktop
- Clone this repository to your new empty project directory.
- Create
.env
file from.env.example
. - Modify
docker-compose.yml
'sdatabase
andmyapp
service names, as needed. Make sure they are unique, in case you are running multiple projects in Docker. - Run application services in Docker
$ docker-compose up -d
- Enable User Authentication pages with VueJS (optional)
docker-compose exec myapp php artisan ui vue --auth
NOTE myapp
service name depends on the changes made on Step 4.
- Install node dependencies
$ docker-compose exec myapp npm install
- Compile Frontend JS and CSS. Keep this command running in a window so that JS will auto-compile with changes in vue files.
$ docker-compose exec myapp npm run watch
- App should be running at
http://localhost:3000
To run commands inside the container:
$ docker-compose exec <app service-name> <command>
Where <app service-name>
is the service name of the app defined in docker-compose.yml
. In this project myapp
is the app service name.
IMPORTANT: When running multiple Laravel projects in Docker, make sure their service names and ports are unique.
- Installing a dependency by Composer
$ docker-compose exec myapp composer require <package-name>
- Applying new
.env
variables
docker-compose exec myapp php artisan config:clear
- After installing a new depenency, run the following command for package re-discovery
$ docker-compose exec myapp composer dump-autoload
- Restart the app service.
$ docker-compose restart myapp
- Stopping the all running services.
$ docker-compose stop
- From time to time, docker image used as base for Laravel will be updated.
- To update the docker image, run the following
$ docker pull docker.io/bitnami/laravel:7-debian-10
$ docker-compose restart myapp