Joustie's blog

Sep 16, 2015 - 2 minute read - agile docker javascript nodejs os-x webstorm

Developing using Webstorm+Docker+nodejs on OS X and debugging it

First install the latest Docker(I use the Mac version for this tutorial) here:   http://docs.docker.com/mac/step_one/ Get Webstorm:  https://www.jetbrains.com/webstorm/ Start the Docker Quick start terminal (see screenshot) You’ll start the default docker vm (linux inside OS X).You can find this later by issuing ‘docker-machine ls’: ![] docker-machine ls Go and download an image inside the docker terminal:Use ‘docker pull ubuntu’docker pull  ubuntu To run an interactive shell in the Ubuntu image: use ‘docker run -i -t ubuntu /bin/bash’docker run -i -t ubuntu /bin/bash Of course we also want to mount our home directory: e.g. use ‘docker run -it -v $HOME:/mnt ubuntu’ Inside the docker host you can find out that your mount is there: ‘ls /mnt’ ls /mntGo and create a folder on the host system that is going to have the app that you want to install for example /Users/thajoust/dev.Create a package.json file by issuing a : ‘npm init’ on the host system in $HOME/dev or create a empty one with: ‘touch $HOME/dev/package.json’ on the host system shell. touch $HOME/dev/package.json Now if you go to the docker terminal and issue the command ‘ls /mnt/dev/’ you will see the package.son file ls /mnt/dev/ You can exit the container by issuing ‘exit’ in the container shell. You now need to run the docker image from the docker terminal to mount the new directory directly : ‘docker run -it -v $HOME/dev:/testApp -w /testApp ubuntu’ Now you will be in the container and you will be able to see the package.son. You can safely delete it now.docker run -it -v $HOME/dev:/testApp -w /testApp ubuntu Next up is installing node in the container: First update the package state: ‘apt-get update’ then: ‘apt-get install nodejs’ apt-get install nodejs Install npm: ‘apt-get install npm’ ![Screen Shot 2015-09-16 at 14.25.19]apt-get install npm Install Node locally: ‘npm install n -g’ npm install n -gFirst install wget:‘apt-get install wget’apt-get install wgetthen:Install latest nodejs:‘n latest’n latestInstall express generator:‘npm install -g express-generator’npm install -g express-generator Inside your testApp folder you can create an express App:‘express my app’ express myappNow we have to introduce a quick workaround for the problem that on some platforms there will be problems with symlinks,. echo “bin-links=false” »$HOME/.npmrc