In this article we will examine the structure of an application that can be deployed on Engine Yard Kontainers.
The Code structure
A sample structure is the following:
. ├── app ├── bin ├── config ├── config.ru ├── db ├── doc ├── Dockerfile ├── Gemfile ├── lib ├── log ├── Procfile ├── public ├── Rakefile ├── README.md ├── script ├── test └── vendor
The above structure is a typical Rails application with two files added: Dockerfile and Procfile.
The application components
Each application consists of one or more pods. A pod on Engine Yard Kontainers includes only one container. The container that will run when the application gets deployed is described in the Dockerfile that exists on the root of your application. In this Dockerfile you can describe the base of your container, the packages to add and many more. So, in order to deploy your application you will need to have a Dockerfile.
Besides the Dockerfile, you may have a Procfile in the root directory of your application. This file describes the name of the pod and the command to run. For example, in the Procfile of the sample-application-3 we define a number of different pods and the respective commands that each one will execute.
The above mean that by having a Dockerfile and a Procfile on the root directory of your application, you are ready to go. During the deployment process the Doeckerfile is automatically detected and triggers a docker image build. This image will be shared among all the processes defined in the Procfile. So, all your pods (== containers) will have the same code/configuration/assets.
There are some special pods names in your application:
- the web pods will be the ones to receive the incoming traffic for your application
- the migration pod will be the one to handle your database migrations