Skip to content

cploutarchou/laravel-dev-infrastructure

Repository files navigation

Containerize a Laravel Application

HOW TO:

Requirements :

  • Docker install instructions link
  • docker-compose install instructions link
  • php composer install instructions link
  • nodejs install instructions link

What you get :

  1. nginx v1.19.6
  2. mysql v8.0
  3. php 7.4-fpm
  4. redis server v6.0.10

Steps :

  1. Run --> composer create-project laravel/laravel example-app
  2. Wait until the composer create the project.
  3. Copy the contents of .env.sample content to .env file.
  4. Run --> composer update
  5. Copy the contents of example-app to root directory
  6. Run php artisan key:generate to generate new app key
  7. Build docker-compose run --> docker-compose up -d
  8. You can access laravel application at http://172.22.1.22
  9. If you get ERROR 500 Check for .env file if file not exists rename .env.sample to .env
  10. And run php artisan key:generate to generate new app key

Mysql Settings:

  • DB_HOST=172.22.1.25
  • DB_PORT=3306
  • DB_DATABASE=laravel
  • DB_USERNAME=laravel
  • DB_PASSWORD=laravel

Redis Settings:

  • REDIS_HOST=172.22.1.23
  • REDIS_PASSWORD=
  • REDIS_PORT=6379

Tips:

If you want to pause your Docker Compose environment while keeping the state of all its services, run: docker-compose pause

You can then resume your services with: docker-compose unpause

To shut down your Docker Compose environment and remove all of its containers, networks, and volumes, run: docker-compose down

If you want to recreate your Docker Compose environment , run: docker-compose up --force-recreate