Node.js

Example of generating a Node.js application:

Using npm init

Generating a package.json

$ mkdir <my-app>
$ cd <my-app>
$ azk shell --image azukiapp/node --shell /bin/bash
# npm init //follow the instructions afterwards
# exit

Creating the Azkfile.js

$ azk init

Using the express-generator module

Generating the project

$ azk shell --image azukiapp/node --shell /bin/bash
# npm install -g express-generator
# express <my-app>
# exit

Creating the Azkfile.js

$ cd <my-app>
$ azk init

Running application

To start the development environment

$ azk start -o && azk logs --follow

Examples

Node with Mongodb

// Adds the systems that shape your system
systems({
  'my-node-app': {
    depends: ['mongodb'],
    image: {'docker': 'azukiapp/node'},
    provision: [
      'npm install',
    ],
    workdir: '/azk/#{manifest.dir}',
    shell: '/bin/bash',
    command: ['npm', 'start'],
    wait: {'retry': 20, 'timeout': 1000},
    mounts: {
      '/azk/#{manifest.dir}': path('.'),
    },
    scalable: {'default': 1},
    http: {
      domains: [ '#{system.name}.#{azk.default_domain}' ]
    },
    ports: {
      http: '8000'
    },
    envs: {
      NODE_ENV: 'dev',
      NODE_PORT: '8000'
    },
  },

  'mongodb': {
    image : { docker: 'azukiapp/mongodb' },
    scalable: false,
    wait: {'retry': 20, 'timeout': 1000},
    mounts: {
      '/data/db': persistent('mongodb-#{manifest.dir}'),
    },
    ports: {
      http: '28017:28017/tcp',
    },
    http: {
      domains: [ '#{manifest.dir}-#{system.name}.#{azk.default_domain}' ],
    },
    export_envs: {
      MONGODB_URI: 'mongodb://#{net.host}:#{net.port[27017]}/#{manifest.dir}_development',
    },
  },
});