Developing a NodeJS app using AppCatalyst

If you own a Mac and are into *nix virtual machines for development, then VMware’s AppCatalyst is a must have because…

AppCatalyst is free!

AppCatalyst is targeting that hip Application/DevOps demographic that loves Macs, Linux, API/Scripting and hates GUIs. You know the same demographic who also loves free stuff for development! I resemble that comment…

Who wouldn’t like AppCatalyst? People with out a Mac, or people running Windows VMs. For that audience there is still VMware Workstation, Fusion and other virtualization alternatives.

I’ll skip the usual unzip instructions as many other blogs have covered the basic install. The remainder will focus on how to integrate AppCatalyst into your development environment using Vagrant and an IDE, in my case it’s IntelliJ, the result will be a simple NodeJS application.

Vagrants and Containers

I’m talking third platform apps, not your local alley bar. AppCatalyst is packaged with project Photon, a container run time host.

VagrantFile : This is a configuration script for vagrant. Vagrant will work with AppCatalyst to magically provision a photon instance, complete with docker daemon and SSL certs so you can communicate remotely with docker. Simply type “vagrant up” from the command line and watch the magic!

DockerSettings directory : Contains a configuration file for docker, container_settings.json. The configuration file sets values such as listening port, volumes, etc. The file is used at build time and is useful for times when you don’t use ‘docker run’, like with an IDE.

B. The .dockerignore file is incredibly important if you don’t want docker to fall over after running a couple of containers. The file works similar to .gitignore but for docker, essentially defining files and directories that should not be placed into the container. In this example, the node_modules directory is ignored as it can get huge and has no business making it into your container.

Now you are ready to run docker on that fancy photon VM you provisioned earlier with Vagrant and AppCatalyst. You can run your container using the command line or using an IDE like IntelliJ.

You can setup IntelliJ with the Docker SSL certs that were created by Vagrant earlier.

Configure IntelliJ for Docker’s API. Set the API URL and the Certificates Folder. The API URL will be the IP of your vagrant VM and the docker API listening on 2376. The Certificates required for communicating docker are in your projects directory under DockerCerts, they were created by the VagrantFile.

Configure IntelliJ to run docker. Navigate to “run” -> “edit configurations” and add a “Docker Deployment”.

Server: Set this to the docker provider you configured previously

Deployment : Set this to the DockerFile in the project

Container Settings : Set this to your container_settings.json file in the project

Deploy your application into a container. 1. navigating to the “Application Servers” tab on the bottom right of intelliJ. 2. Press the deploy button.

When docker is done, you will see the following message stating that the container has successfully deployed.

You can now browse to the IP and Port (http://vagrantIP:8081) of your container to see the hello world message.

Note: The ability to use code injection for nodeJS with nodemon is very desirable as you can simply update your code and see real time results as it is mapped into the container. Unfortunately, I haven’t found a way to make this work with the container_settings.json. In theory you should be able to map a volume in the container settings similar to ‘docker run -v’. If you want to use code injection then you are stuck using docker run -v at this time.