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

Creating a Docker Container for Angular Yeoman Application.

The prerequisite of course is to install Docker and create a Docker hub account (free).
See Docker Installation Documentation.

A typical Ubuntu Docker container requires more than a 1GB download.

Step1:
Create your angular-yeoman application (my-app) by following this Link

Step2:
Add a Dockerfile file to the my-app directory:

FROM node:boron

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY   . /usr/src/app

RUN     npm install -g bower
RUN     npm install -g grunt-cli
RUN     npm install
RUN     bower install –allow-root
#RUN     grunt –force
EXPOSE 9000
CMD     [“grunt”, “serve”]

Step3:
Open you Gruntfile.js and go to your grunt server settings. Change hostname of your
Grunt from `localhost` to `0.0.0.0`

Step4:
Inside your my-app directory

Build your image
$ docker build -t docker-hub-username/my-app .

Run your image
$ docker run -p 9000:9000 docker-hub-username/my-app

You can also run the above command with -d flag that will run your container in the
background.

$ docker run -p 9000:9000 -d docker-hub-username/my-app

To see your modified code in docker container you have to run your container
after rebuilding the docker image. In order to mount your changes in docker container without rebuilding the image, you can run following command

$ docker run -p 9000:9000 -v /var/www/my-app/:/usr/src/app docker-hub-username/my-app

NOTE: In above command you have to replace `/var/www/my-app/` with the path of your my-app directory.