This is a Dockerized Laravel Application built using the following containers:
-
PHP Application
`PHP8.0-fpm, Composer, NPM,
-
MySQL
-
Nginx
- Docker Engine (v19.03.0+)
- Docker Compose
You can either:
- Install Docker Desktop (includes both Docker Engine and Docker Compose)
OR
- Install Docker Engine and Docker Compose separately.
-
Open a new instance of the terminal, navigate to the root directory of the project and execute the following command to bring all the containers up.
$ docker-compose up -d
The command will take a while to run, since it will download/build the images for the first time. After the images are ready, it will start the containers. The next time you run this command it will be way faster to execute.
note: any change you make to the Dockerfile or any other file that the Dockerfile uses (excluding docker-compose.yaml) you will need to build the images again for the changes to take effect by executing the following command.
$ docker-compose build && docker-compose up -d
-
When all containers are up and running, enter the app container by executing the following command.
$ docker-compose exec -ti app /bin/bash
-
Install all composer packages included in composer.json
$ composer install
-
Install all npm packages included in package.json
$ npm install
-
Run all mix tasks.
$ npm run dev
-
Create a .env file from the existing .env.example
$ cp .env.example .env
-
Generate a Laravel App Key.
$ php artisan key:generate
-
Run the database migrations.
$ php artisan migrate
-
Modify the following fields in your .env file to use the values specified in the database container.
DB_CONNECTION=mysql DB_HOST=db DB_PORT=3306 DB_DATABASE=Data DB_USERNAME=root123 DB_PASSWORD=root123
-
To access your Laravel Application visit http://localhost:8000
-
Exit the app container.
$ exit
-
Bring all the containers down.
$ docker-compose down