How to deploy your apps on anynines
FeaturedNote: This guide uses the Cloud Foundry CLI version 5. The instructions below are not compatible with any cf version > 5. Click here to get a description of the differences between CLI v5 and CLI v6.
Software requirements
Before you start it's necessary to install two small applications on your system: Ruby 1.9.3 and a9s.
To install Ruby 1.9.3 you can follow the instructions on the offical ruby page:
http://www.ruby-lang.org/en/downloads/
After you've installed Ruby, go to your command line and install the a9s gem which downloads the needed gems for interacting with the anynines system (cf, cfoundry):
gem install a9s
You can check all available cf sub-commands by typing:
cf help
Login
Now you need to select the anynines api endpoint as target and authenticate with the auth service using your user credentials:
cf target https://api.aws.ie.a9s.eu cf login --email [your@email] --password [yourpassword]
Spaces & Organizations
Anynines provides 2 major units for structuring your PaaS environment. Organizations are used to organize users within a common unit. Spaces are used to organize your application instances within separate environments (e.g. test, staging, production). Please refer to the official Cloud Foundry documentation for more information about spaces and organizations.
You can check your current space and organization using the target command.
cf target
!Note!
We're developing a web interface for our customers. When it is released you will be able to administer spaces and manage user relations and roles for them.
Rails Example Application: If you'd like to test anynines without deploying one of your own applications, feel free to use our rails example application for testing a deployment. You can checkout the sources at https://github.com/anynines/simple_rails_app.
It is recommended to pre-compile your assets locally before pushing the application to the server. You can achieve this by executing the concerning rake task from your application directory:
cd [your-app-directory] bundle exec rake assets:precompile
You can deploy your code by using the push command now.
cf push
A wizard will guide you through the configuration process:
Name: Give your application a name.
Instances: How many instances of your application should be started? Enter 1, 2, 3 or more and load balancing is set up automatically.
Custom startup command: In the most cases you don't have to specify this option. Anynines knows how to start the app if you use a framework like Rails.
Memory Limit: Choose a memory limit for each application instance.
Subdomain: Choose a subdomain for your application. You can choose the domain itself by the next question.
Domain: In context of the subdomain this represent the actual url your application is located. By default there will be only "aws.ie.a9sapp.eu" available. After the deployment finished you can open "[Subdomain].aws.ie.a9sapp.eu" in your browser and you will see whether the app is running.
Create services for application: Type "y" and you can choose from services like mysql, mongodb, etc. They will be configured for your application automatically. You can name your service instance for better tidiness within your spaces.
After that you can add and configure more services if they are needed by your application.
Save configuration: If you type "y" the system will create a new file in your project path called "manifest.yml" which contains the configuration for your app's deployment on anynines. This configuration will be used in future deployments.
Execute database migrations (Rails)
If your application uses a database like MySQL or PostgresSQL you have to setup your database schema. You can use the rails console to achieve this by using backquotes for running shell commands from the irb console:
cf console [Your-App-Name]
`bundle exec rake db:migrate`
It is also possible to place your migration execution within a rails initializer as described here.
That's it, your app is up and running in the cloud!
Additional Information
You can use the cf apps command to get a status list of your applications running within the current space.
cf apps
In addition you can retrieve log information containing the application's current environment variables and log outputs by using the cf logs command:
cf logs [Your-App-Name]
For troubleshooting and help related to application deployments please refer to the How to debug an aborted deployment article.
Further Reading & Troubleshooting
Please refer to our other articles to dive deeper into more advanced topics and deployment scenarios. If you experience problems during your deployment please refer to our Troubleshooting section.
Please sign in to leave a comment.
Comments
0 comments