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.

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