app dockerfile

romant authored
revision 87e6af2371ae15a1e5dfeacf139d9cb1147c64a3
document
# 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.

## What do you need?
- A Mac
- AppCatalyst
> The official documentation for interacting with AppCatalyst can be found [here](http://getappcatalyst.com/docs/)
- 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` ๐Ÿ˜ณ

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

![overview_architecture]

## Getting there

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

1. Install AppCatalyst
1. Install [Docker Toolbox](https://www.docker.com/toolbox)
1. Replace docker-machine with the VMware AppCatalyst builtin
`curl https://dl.dropboxusercontent.com/u/23974/docker-machine-ac -o /usr/local/bin/docker-machine ; chmod +x !$`
1. Start the AppCatalyst-Daemon

`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

```
my_app
โ”œโ”€โ”€ 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 app\
vi Dockerfile
```
.. and paste the contents of [insert GitHub url for the Dockerfile]following

```
FROM romant/node:meteor

MAINTAINER Your Name

EXPOSE 3000

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
```

Technically, as soon as this is finished 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

### Database

### Putting it Together
You can manually create links between the different containers at the time of creation, and that works wonderfully; and you can also use Docker-Compose

[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