Dockerize your Laravel-postgres Application using Laradock

Step1:
Install docker compose in you system.

Step2:
Clone Laradock in your Laravel project
$ git clone https://github.com/Laradock/laradock.git

Step3:
Enter the laradock folder and rename env-example to .env.
$ cp env-example .env

At the top, change the APPLICATION variable to your project path.
APPLICATION=../

Step4:
Replace your project/.env DB variable with the following

DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret

Step5:
Run
$ docker-compose up -d nginx postgres

It will take sometime to create images in your system.

Step6:
Configure your project

$ docker-compose exec workspace bash
$ composer install
$ php artisan migrate
$ php artisan db:seed

If installing a new project then you have to run the following commands as well

$ php artisan key:generate
$ sudo chmod -R 777 storage bootstrap/cache

Note:
If you modify docker-compose.yml, .env or any dockerfile file, you must re-build your containers, to see those effects in the running instance. For more information please check Laradock documentation

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s