- grammarz & port explicitness

Roman Tarnavski authored
revision c5376eede5b95ad4ffb937f79798ef664d821d73
# Getting started with AppCatalyst and Docker
"VMware AppCatalyst is an API and Command Line Interface (CLI)-driven Mac hypervisor that is purpose-built for developers, with the goal of bringing the datacenter to the desktop."

Using it we will build out a simple, but an effective way to demonstrate the ease of use of AppCatalyst, rapid nature with which we can model a modern Meteor application using Docker.

## Before you begin
AppCatalyst is still in Tech Preview. Therefore for the purpose of this walkthrough, all builds of components must be tightly controlled for repeatability of experience.

## What do you need?
- A Mac
- AppCatalyst `Build # 2836636`
> The official documentation for interacting with AppCatalyst can be found [here](http://getappcatalyst.com/docs/)
- Docker Client `version 1.7.1, build 786b29d`
- Fabio's _special_ build of [Docker-Machine](https://github.com/frapposelli/machine/commit/7d3d7bf6309c36459e9261b497802d96ba847c36). You can make the binary from scratch; or use the OSX Binary.
> NOTE: There is no support for this code.

## Final Result
- Once completed all the steps you will end up with an application that is the meteor sample [todos App](https://www.meteor.com/todos) running across multiple containers, within VMware Photon, atop AppCatalyst, instrumented via `docker-machine` ๐Ÿ˜ณ

- As far as the overall architecture, it's _similar_ to a typical multi-tier app.


## Getting there

### Developer Infrastructure
> *Recommended:* alias the docker-machine command
> `alias dm=docker-machine`

1. Install AppCatalyst
1. Install Docker Client
`curl https://get.docker.com/builds/Darwin/x86_64/docker-1.7.1 -o /usr/local/bin/docker && chmod +x /usr/local/bin/docker`

1. Install docker-machine which has VMware AppCatalyst driver built-in
`curl https://dl.dropboxusercontent.com/u/23974/docker-machine-ac -o /usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine`

1. Start the AppCatalyst-Daemon

> NOTE : Assuming you've followed the AppCatalyst documention, and added it to your PATH. Otherwise you'll need to refer to the command by the full path of `/opt/vmware/appcatalyst/bin/appcatalyst-daemon`

1. Create the appcatalyst, docker-machine endpoint

`dm create -d vmwareappcatalyst tokyo`
> NOTE : We're indicateing via the `-d` flag the driver to use, in this case `vmwareappcatalyst`. Followed by a friendly name `tokyo`

1. Set our environment to point to this newly created docker host

`dm env tokyo`

โ˜๏ธ_follow the onscreen instructions_

### Application

1. Create the working structure for your application

`mkdir -p my_app/{app,data,compose}`

It should now resemble

โ”œโ”€โ”€ app
โ”œโ”€โ”€ compose
โ””โ”€โ”€ data

> NOTE : we've cheated a little, and am skipping a small step, as am providing a Meteor-ready container for our sample todos app

1. Create the app container
cd my_app/app/
vi Dockerfile
.. and paste the following

FROM romant/node:meteor



WORKDIR /home/app

RUN meteor create --example todos

ENTRYPOINT cd /home/app/todos && meteor

1. Build the docker image

`docker build -t romant/todos .`

> Depending on the internet connection speed, you should see the build start, and the display resemble something close to the following

Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM romant/node:meteor
meteor: Pulling from romant/node
902b87aaaec9: Downloading [> ] 519.1 kB/51.37 MB
9a61b6b1315e: Download complete
1ff9f26f09fb: Downloading [> ] 186 kB/18.54 MB
607e965985c1: Downloading [> ] 437.2 kB/42.37 MB
e3b4bca8cea6: Downloading [> ] 539.7 kB/127.5 MB
21cc4c536cdb: Download complete
e460f18e2989: Download complete
6e68158502bf: Download complete
64c7bdd0de42: Pulling fs layer
3bba441d8886: Pulling fs layer
e115fe109a33: Download complete

Ending with

`Successfully built 9e43ffe38c97`

1. List the images that are now available for you to use

docker images
romant/todos latest 9e43ffe38c97 6 seconds ago 922 MB
romant/node meteor 2539fa2fe41f 5 weeks ago 915.8 MB

You successfully built an image, and you can see the base image upon which the `Dockerfile` was built upon `romant/node`

1. Let's go ahead, and run our app

`docker run -d -p 80:3000 romant/todos`

1. Point your browser _justo the IP_ (without the port) which corresponds to the environment endpoint from `docker-machine` in the URL column

`dm ls`

dockerMeetup vmwareappcatalyst Stopped
testpan virtualbox Stopped
tokyo * vmwareappcatalyst Running tcp://
wheat vmwareappcatalyst Stopped

You should now have the finished product as depicted in the screenshowt earlier in the guide.

> Part 1 of the lab is finished, you can start the Meteor app without a database, because it has an inbuilt _mini_ MongoDB; scope of which is beyond this lab. We will instead ignore this, and continue to having it connect to a dedicated MongoDB environment we build in the next step

[todos_screenshot]: https://cloud.githubusercontent.com/assets/49066/9328513/3a01c142-45e4-11e5-88e1-26a5dc6dd6f0.png

[overview_architecture]: https://cloud.githubusercontent.com/assets/49066/9346143/29f21a0c-4654-11e5-87a7-a6b8827415db.png