Skip to content

Instantly share code, notes, and snippets.

@gullitmiranda
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gullitmiranda/521d833f2ab9ce3c2780 to your computer and use it in GitHub Desktop.
Save gullitmiranda/521d833f2ab9ce3c2780 to your computer and use it in GitHub Desktop.
Azkfile.js
/**
* Documentation: http://docs.azk.io/Azkfile.js
*/
function ruby_system(command, extra) {
var merge = require('azk')._.merge;
var extra = extra || {};
return merge({
// 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: { retry: 3, timeout: 1000 },
scalable: { "default": 2 },
// Mounts folders to assigned paths
mounts: {
// equivalent mount_folders
'/azk/#{manifest.dir}' : path('.'),
'/www/gems' : path('../gems', { required: false }),
'/azk/bundler' : persistent('bundler'), // Volume nomed
},
http: {
// aircrm.azk.dev
domains: [ "#{system.name}.#{azk.default_domain}" ]
},
envs: {
// set instances variables
RACK_ENV: "development",
HOST: "#{system.name}.#{azk.default_domain}",
MERCADOLIBRE_APP_ID: 1234567890123345678,
MERCADOLIBRE_APP_SECRET: "abc123abc123abc123abc123",
},
export_envs: {
HTTP_PORT: "#{azk.default_domain}:#{net.port.http}",
HTTPS_PORT: "#{azk.default_domain}:#{net.port.http}"
}
}, extra);
};
// Adds the systems that shape your system
systems({
aircrm : ruby_system('rails server --pid /tmp/rails.pid --port $HTTP_PORT'),
sidekiq: ruby_system('sidekiq', {
// Disable balancer and wait
http: null,
wait: false,
}),
mongodb: {
image : "dockerfile/mongodb",
scalable: false,
ports: {
http: "28017",
},
http : {
// aircrm-mongodb.azk.dev
domains: [ "#{manifest.dir}-#{system.name}.#{azk.default_domain}" ],
},
// Mounts folders to assigned paths
mounts: {
// equivalent persistent_folders
'/data/db' : persistent('mongodb'), // Volume nomed
},
export_envs : {
MONGODB_URI: "mongodb://#{net.host}:#{net.port[27017]}/aircrm_development",
},
},
postgres: {
image: "wyaeld/postgres:9.3",
scalable : false,
// Mounts folders to assigned paths
mounts: {
// equivalent persistent_folders
'/var/lib/postgresql' : persistent('postgresql'), // Volume nomed
'/var/log/postgresql' : path('./log/postgresql'),
},
ports: {
data: "5432/tcp",
},
envs: {
// Move this to .env file
POSTGRESQL_USER: "admin",
POSTGRESQL_PASS: "alguma_senha",
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",
scalable : false,
ports: {
data: "6379/tcp",
},
export_envs: {
REDIS_URL: "redis://#{net.host}:#{net.port.data}/#{manifest.dir}"
},
// Mounts folders to assigned paths
mounts: {
// equivalent persistent_folders
'/data' : persistent('redis'), // Volume nomed
},
},
mail: {
image : "kdihalas/mail",
scalable : false,
http : {
domains: [ "#{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/docker-ngrok",
// Mounts folders to assigned paths
mounts: {
// equivalent persistent_folders
'/#{system.name}' : path("./log"),
},
scalable: { default: 0, limit: 1 }, // disable auto start
// not expect application response
wait: false,
http : {
domains: [ "#{manifest.dir}-#{system.name}.#{azk.default_domain}" ],
},
ports : {
http : "4040"
},
envs : {
NGROK_LOG : "/#{system.name}/log/ngrok.log",
NGROK_SUBDOMAIN : "aircrm-ml",
NGROK_AUTH : "abc123abc123abc123",
}
}
});
// 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