Dokku and NodeJS + AngularJS Apps

October 24, 2014 1.9k views


We're new to DO and we are deploying a set of apps that use Node for API and Angular for frontend code, and we're using Dokku as the app container. We are facing a bit of difficulty because of the lack of Dokku documentation, but since there seams to be a lot of people using Dokku with DO maybe someone can help us.

1 - We run bower install in the post install script (so to not have bower components in git), and since we have node as a layer between nginx and the browser it supplies te frontend code as well using a "static" route. The problem is that the components downloaded during the post install seem to have a "special" state that prevents them from being access via http request. We canot fully understand what is wrong, but the solution is to just touch the files after the down load, so we put this in the post install script && find ./frontend -exec touch {} \; . This works but we would like to understand why. Does anyone have any idea?
2 - During the setup of the build process we had to install SASS by hand in the app container, but of course it doesn't stick, so we put gem install sass in the post install as well. Is there a way to do this better?
3 - Is there a way to defined the version of mongodb that gets install using the mongodb plugin, and it there a way to externally connect to a mongodb instance?

Thanks in advance for your help

Ricardo Gomes

1 Answer

The bower issue does seem very strange. When you say that the resources can not be accessed via HTTP request, what exactly is the error? Just 404? Can you reproduce it using the dokku-bower-install plugin? It simply injects a script that is run in the "pre-deploy" phase:


cd /app
if [[ -f ./bower.json ]]; then
    npm install -g bower && bower install --allow-root

I'm not sure why that would work but your approach wouldn't, but it might rule some things out...

As for connecting to an external MongoDB, if you app respects environmental variables you should be able to pass them into the container using:

dokku config:set <app> KEY1=VALUE1
  • Thanks Andrew

    We hadn't come across that plugin yet. Will try it and report back.

    The fail to get the bower files via http is more complex than a 404. Because our node defaults all requests to the index.html for angular. But essentially it seams that node cannot see the file until the touch.

    Now the mongo question was the other way around (probably my not good enough english, sorry). Is there any way to get to mongo from the outside, say using robomongo locally? Maybe an ssh tunnel to the mongodb container?

Have another answer? Share your knowledge.