Skip to content

Instantly share code, notes, and snippets.

@nuxlli
Last active August 29, 2015 14:06
Show Gist options
  • Save nuxlli/b90e99081dd61347dedb to your computer and use it in GitHub Desktop.
Save nuxlli/b90e99081dd61347dedb to your computer and use it in GitHub Desktop.

Development Environment

This project automates the setup of a development environment for Ruby on Rails. This is the easiest way to build a box with everything ready to start hacking, all in an isolated.

Requirements
  • azk
  • terminal =)

Install azk and Start Project
  1. Install azk:

  2. Check if azk agent is running:

$ azk agent status
  1. Clone the application locally:
$ git clone git@bitbucket.org:aircrm/aircrm.git
  1. Execute the application:

    NOTE:the first boot may take a few minutes because it will make downloading the images and provisioning systems

$ azk start
$ azk status
  1. Access the application through the azk built-in balancer:
$ open http://aircrm.azk.dev
/**
* Documentation: http://docs.azk.io/Azkfile.js
*/
var ruby_system = function(command) {
return {
// Dependent systems
depends: ["postgres", "mongodb", "redis", "mail"],
// More images: http://images.azk.io
image: "gullitmiranda/ruby",
// Steps to execute before running instances
provision: [
"bundle install --path /azk/bundler",
"bundle exec rake db:create",
"bundle exec rake db:migrate",
],
workdir: "/azk/#{manifest.dir}",
command: "bundle exec " + command,
shell: "/bin/bash",
// not expect application response
wait: false,
// Mounts folders to assigned paths
mount_folders: {
'.': "/azk/#{manifest.dir}",
// '../gems': "/www/gems"
},
persistent_folders : [ "/azk/bundler" ],
scalable: {"default": 1},
http: {
// aircrm.azk.dev
hostname: "#{system.name}.#{azk.default_domain}"
},
envs: {
// set instances variables
RUBY_ENV: "development",
RACK_ENV: "development",
RAILS_ENV: "development",
ENABLE_AZK: true,
HOST: "#{system.name}.#{azk.default_domain}",
MERCADOLIBRE_APP_ID: 5227026097385184,
MERCADOLIBRE_APP_SECRET: "6PLlf1ybZP9RyM6jZYvxHpUDgejpEuP5",
},
export_envs: {
HTTP_PORT: "#{azk.default_domain}:#{net.port.http}",
HTTPS_PORT: "#{azk.default_domain}:#{net.port.http}"
}
}
}
// Adds the systems that shape your system
systems({
aircrm: ruby_system('rails server --port $HTTP_PORT --pid /tmp/rails.pid'),
sidekiq: ruby_system('sidekiq'),
mongodb: {
scalable: false,
ports: {
http: "28017",
},
http : {
// aircrm-mongodb.azk.dev
hostname: "#{manifest.dir}-#{system.name}.#{azk.default_domain}",
},
persistent_folders : [ "/data/db" ],
image : "dockerfile/mongodb",
export_envs : {
MONGODB_URI: "mongodb://#{net.host}:#{net.port[27017]}/aircrm_development",
},
},
postgres: {
scalable: false,
image: "wyaeld/postgres:9.3",
persistent_folders: [ "/var/lib/postgresql" ],
ports: {
data: "5432/tcp",
},
envs: {
// Move this to .env file
POSTGRESQL_USER: "admin",
POSTGRESQL_PASS: "oe9jaacZLbR9pN",
POSTGRESQL_DB : "aircrm_development",
POSTGRESQL_HOST: "#{net.host}",
POSTGRESQL_PORT: "#{net.port.data}",
},
export_envs: {
DATABASE_URL: "postgres://#{envs.POSTGRESQL_USER}:#{envs.POSTGRESQL_PASS}@#{net.host}:#{net.port.data}/#{envs.POSTGRESQL_DB}",
},
},
redis: {
image: "dockerfile/redis",
ports: {
data: "6379/tcp",
},
export_envs: {
REDIS_URL: "redis://#{net.host}:#{net.port.data}/#{manifest.dir}"
},
persistent_folders: [ "/data" ]
},
mail: {
image : "kdihalas/mail",
scalable : { default: 1 },
http : { hostname : "#{manifest.dir}-#{system.name}.#{azk.default_domain}" },
ports : {
smtp : "25:25/tcp",
http : "1080/tcp"
},
export_envs: {
MAIL_PORT: "#{net.port.smtp}",
},
},
ngrok: {
// Dependent systems
depends: ["aircrm"],
image : "gullitmiranda/ngrok",
mount_folders: {
'./log': "/#{system.name}/log",
},
scalable : false,
http : { hostname : "#{manifest.dir}-#{system.name}.#{azk.default_domain}" },
ports : {
http : "4040"
},
envs : {
NGROK_LOG : "/#{system.name}/log/ngrok.log",
NGROK_SUBDOMAIN : "aircrm-ml",
NGROK_AUTH : "ehXzJi7CGRc8jj74W1Ed",
}
}
});
// Sets a default system (to use: start, stop, status, scale)
setDefault("aircrm")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment