Question

I am wanting to know how to go about deploying my docpad project to modulus.

Assuming I need to be running in production mode to do so. I noticed for the static deployment on docpad you just upload the contents of the out directory. If we are using a node server do we upload the entire project direcory. Which I did try but I don't think my docpad.coffee settings were correct. You can see below my attempt at this.

docpad.coffee

    # ----------------
    # Server Configuration
    # Server Express
    # ----------------
    # The express.js instance that we want DocPad to use
    # If not set, we will create our own
    serverExpress: default



    # ----------------
    # Port
    # ----------------
    # Use to change the port that DocPad listens to
    # By default we will detect the appropriate port number for our environment
    # if no environment port number is detected we will use 9778 as the port number
    # Checked environment variables are:
    # - PORT - Heroku, Nodejitsu, Custom
    # - VCAP_APP_PORT - AppFog
    # - VMC_APP_PORT - CloudFoundry
    port: - PORT

The First step according to the modulus site is to Use the environment variable PORT. app.listen(process.env.PORT) I assumed that would meant adding the - PORT to the docpad.coffee file.

As well I am not even sure how to have the site run in production when uploaded, remember I am just uploading the entire directory. Do I run a command from the Modulus server in terminal once the project is deployed?

Modulus also asks for the following in my packages.json file. I had most of them already except for the "main": "path/to/custom_main.js" which I assumed was the docpad.coffee file, so I linked to that.

Package.json

    {
  "name": "zurb-foundation.docpad",
  "version": "0.4.0",
  "description": "Zurb Foundation skeleton for DocPad. Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.",
  "homepage": "https://github.com/axyz/zurb-foundation.docpad",
  "keywords": [
    "docpad-skeleton",
    "docpad",
    "website",
    "foundation",
    "zurb foundation"
  ],
  "author": "Andrea Moretti <axyzxp@gmail.com>",
  "maintainers": [
    "Andrea Moretti <axyzxp@gmail.com>"
  ],
  "contributors": [
    "Andrea Moretti <axyzxp@gmail.com>"
  ],
  "bugs": {
    "url": "https://github.com/axyz/zurb-foundation.docpad/issues"
  },
  "repository": {
    "type": "git",
    "url": "http://github.com/axyz/zurb-foundation.docpad.git"
  },
  "engines": {
    "node": "0.10",
    "npm": "1.3"
  },
  "main": "docpad.coffee",
  "dependencies": {
    "docpad": "~6.54.1",
    "docpad-plugin-eco": "~2.0.2",
    "docpad-plugin-livereload": "~2.5.3",
    "docpad-plugin-coffeescript": "~2.2.2",
    "express" : "2.5.x",
    "ejs" : "0.8.x",
    "docpad-plugin-nodesass": "~2.1.1"
  },
  "main": "node_modules/docpad/bin/docpad-server",
  "scripts": {
    "start": "node_modules/docpad/bin/docpad-server"
  },
  "devDependencies": {}
}

When I Deployed the site it did not work at all, I mean I had a link but the site didnt work. Any suggestions on what to do when deploying a docpad site to Modulus? I used the skeleton Foundation with Sass as well after installing docpad, which did work locally.

Ok still trying to get this thing working, when I run the site now it works locally, and when I deploy it I get a link to a modulus subdomian that doesnt work. I went and checked the logs on the modulus site and this is what I get

Modulus Logs

...

docpad-plugin-coffeescript@2.2.2 node_modules/docpad-plugin-coffeescript
└── coffee-script@1.6.3

docpad-plugin-eco@2.0.2 node_modules/docpad-plugin-eco
└── eco@1.1.0-rc-3 (strscan@1.0.1, coffee-script@1.6.3)

express@2.5.11 node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.9.2 (formidable@1.0.14)

docpad-plugin-livereload@2.5.3 node_modules/docpad-plugin-livereload
├── extendr@2.1.0 (typechecker@2.0.8)
├── primus@1.4.4 (extendable@0.0.6, load@1.0.0)
└── ws@0.4.31 (tinycolor@0.0.1, options@0.0.5, commander@0.6.1, nan@0.3.2)

docpad@6.54.4 node_modules/docpad
├── lazy-require@1.0.0
├── eachr@2.0.2
├── extendr@2.1.0
├── extract-opts@2.2.0
├── caterpillar-filter@2.0.3
├── envfile@1.0.0
├── getmac@1.0.6
├── commander@2.0.0
├── ambi@2.1.6
├── typechecker@2.0.8
├── taskgroup@3.3.0
├── mime@1.2.11
├── query-engine@1.5.3
├── bal-util@2.3.2
├── safefs@3.0.3 (taskgroup@3.2.4)
├── semver@2.2.1
├── safeps@2.2.8 (taskgroup@3.2.4)
├── caterpillar-human@2.1.1 (ansistyles@0.1.1, ansicolors@0.2.1)
├── progressbar@1.0.3 (progress@1.1.2)
├── event-emitter-grouped@2.3.1 (taskgroup@3.2.4)
├── watchr@2.4.4 (taskgroup@3.2.4)
├── promptly@0.2.0 (read@1.0.5)
├── backbone@1.1.0 (underscore@1.5.2)
├── jschardet@1.1.0
├── superagent@0.15.7 (methods@0.0.1, cookiejar@1.3.0, debug@0.7.3, qs@0.6.5, emitter-component@1.0.0, reduce-component@1.0.1, mime@1.2.5, formidable@1.0.14)
├── lodash@2.2.1
├── cson@1.4.5 (requirefresh@1.1.2, coffee-script@1.6.3, js2coffee@0.2.3)
├── caterpillar@2.0.6 (readable-stream@1.1.9)
├── encoding@0.1.7 (iconv-lite@0.2.11)
├── yamljs@0.1.4 (glob@3.1.21, argparse@0.1.15)
└── express@3.4.4 (methods@0.1.0, range-parser@0.0.4, cookie-signature@1.0.1, fresh@0.2.0, debug@0.7.3, buffer-crc32@0.2.1, cookie@0.1.0, send@0.1.4, mkdirp@0.3.5, commander@1.3.2, connect@2.11.0)

docpad-plugin-nodesass@2.1.1 node_modules/docpad-plugin-nodesass
├── node-neat@1.0.0
├── node-bourbon@1.0.0
├── taskgroup@3.2.4 (ambi@2.1.6)
└── node-sass@0.7.0 (node-watch@0.3.4, colors@0.6.0-1, mkdirp@0.3.5, optimist@0.6.0, mocha@1.13.0)
INFO: Main file specified in package.json: node_modules/docpad/bin/docpad-server
INFO: Starting application.
[32minfo:[39m Welcome to DocPad v6.54.4 (global installation: /mnt/data/2/node_modules/docpad)
[32minfo:[39m Contribute: http://docpad.org/docs/contribute
[32minfo:[39m Plugins: 
[32minfo:[39m Environment: production
[32minfo:[39m DocPad listening to http://localhost:8080/ on directory /mnt/data/2/node_modules/docpad/bin/out
[32minfo:[39m Generating...
[33mnotice:[39m DocPad is currently running without any plugins installed. You probably want to install some: http://docpad.org/plugins
Error: Cannot generate website as the src dir was not found
    at /mnt/data/2/node_modules/docpad/out/lib/docpad.js:3102:21
    at /mnt/data/2/node_modules/docpad/node_modules/safefs/out/lib/safefs.js:185:16
    at Object.cb [as oncomplete] (fs.js:168:19)
[2013-11-03T17:19:32.095Z] Application initialized with pid 69363

The entire log file can be seen here https://gist.github.com/kitsondevelopment/7292623

It says it cant find the src directory however the source directory is there according to this screen shot so I do not understand.

enter image description here

Update

I just noticed that the error it is referring to the src directory in the node_modules/docpad directory, my app created with docpad run did not have a src directory in node_modules/docpad. WHy might this be?

Was it helpful?

Solution

Update:

It appears that modulus does something odd when just using package.json to set docpad as the entry point. My guess is that it doesn't set the current directory correctly.

I got it working by creating an app.js that just hands off execution to docpad (similar to the deployment instructions for AppFog:

module.exports = require(__dirname+'/node_modules/docpad/out/bin/docpad-server');

Then in package.json, I pointed main at app.js

"engines" : {
    "node": "0.10",
    "npm": "1.2"
},
"dependencies": {
    ... the dependencies from the skeleton ...
},
"main": "app.js",

===

You shouldn't set serverExpress at all. Remove that set of lines. You also shouldn't set port. The port setting in docpad.coffee is only if you want to hard code a specific port (which you don't). docpad will automatically look at all of the environment variables typically used by node hosts (including the one that Modulus is setting) and will figure out the correct port without you doing anything special.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top