Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A little builder to automatically use NPM on the DotCloud custom service

  • Loading branch information...
commit 069c422a8243d21f71fece5e2a8133ea85dc5953 0 parents
Louis Opter authored
Showing with 52 additions and 0 deletions.
  1. +26 −0 builder
  2. +6 −0 dotcloud.yml
  3. +9 −0 package.json
  4. +11 −0 server.js
26 builder
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+name=nodejs
+
+packages_dir=node_modules
+
+install_dependencies() {
+ # Some user have their packages in their repository let's remove them,
+ # there is good chances that we are on a different architecture anyway.
+ [ -e "$packages_dir" ] && rm -rf "$packages_dir"
+
+ # Fool npm to install packages in $HOME, this way we don't need to
+ # re-install them at each push
+ [ -d "$HOME/data/$packages_dir" ] || mkdir -p "$HOME/data/$packages_dir"
+ ln -s "$HOME/data/$packages_dir/"
+
+ # Finally install the specified dependencies.
+ [ -f package.json ] && npm install
+}
+
+install_application() {
+ rsync -aH --delete --exclude "data" * $HOME/
+}
+
+install_dependencies
+install_application
6 dotcloud.yml
@@ -0,0 +1,6 @@
+nodejs:
+ type: custom
+ buildscript: builder
+ ports:
+ www: http
+ process: node server.js
9 package.json
@@ -0,0 +1,9 @@
+{
+ "name": "naive",
+ "description": "A package using naive versioning",
+ "author": "A confused individual <iam@confused.com>",
+ "version": "0.0.1",
+ "dependencies": {
+ "redis": "0.6.7"
+ }
+}
11 server.js
@@ -0,0 +1,11 @@
+var http = require('http');
+
+process.on('SIGTERM', function () {
+ console.log('Got SIGTERM exiting...');
+ process.exit(0);
+});
+
+http.createServer(function (req, res) {
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end('Hello World\n');
+}).listen(process.env['PORT_WWW'], "0.0.0.0");
Please sign in to comment.
Something went wrong with that request. Please try again.