One line deploy¶
After you’ve built your Hoodie app you probably want to put it online. You can choose to deploy your app as read-only or deploy the backend couchdb database as well. This video and the text below describes how to deploy your app using one line of code. Alternatively, you can deploy your app using Docker, please refer to the Docker section.
Deploying to Now¶
Now allows you to deploy a Node application with its command line tool. It’s 100% free for Open Source projects. You can deploy an app from your computer or right from a GitHub repository. For example, to deploy our Hoodie Tracker demo app all you have to do is to run this command:
$ now hoodiehq/hoodie-app-tracker --npm -e NODE_ENV=production -e hoodie_inMemory=true
To describe this further:
hoodiehq/hoodie-app-trackeris the GitHub repository slug.
--npmtells now to deploy using npm as there is also Dockerfile in the repository.
-e NODE_ENV=productionsets the NODE_ENV environment variable to production, which makes the deployment faster as no devDependencies will be installed.
-e hoodie_inMemory=truemakes the Hoodie app run in-memory mode, meaning that no data is persisted and no files are written. This is important because now is a read-only file system. That means that all user accounts and data will be lost on the next deployment, but it is great for for a quick test or demo of your application.
Alternatively, add this script to your package.json and you are good to go:
"now-start": "hoodie --inMemory",
Store Data With Cloudant¶
Cloudant is a DBaaS (database-as-a-service). It provides most of CouchDB’s APIs and can be used as Hoodie’s database backend. Signing up for a free account only takes a moment. After sign up, you need to slightly adjust the now deployment command above.
$ now hoodiehq/hoodie-app-tracker -e NODE_ENV=production -e hoodie_inMemory=true -e hoodie_dbUrl=https://username:email@example.com/
hoodie_inMemory environment variable makes sure that Hoodie does not try to write any files like the bundled /hoodie/client.js library. The
hoodie_dbUrl environment variable sets the address and credentials to your CouchDB. Replace username and password to whatever you signed up with.
Test and set an alias¶
When you deploy with now you will receive a random subdomain where you can access your application. It looks something like https://hoodie-app-tracker-randomxyz.now.sh/ and was already copied to your clipboard during the deployment. Open the URL in your browser to give it a try. Once everything is good, you can change the subdomain to your preference by running:
$ now alias set hoodie-app-tracker-randomxyz my-tracker-app
Deployment in linux¶
This guide is for Linux only at this point. I have tried to deploy Hoodie-App-Tracker as an example:
We assume you set up CouchDB with your package manager or manually following the installation procedure.
In order to test if CouchDB is running fine or not, we can simply run the following command which will retrieve the information through curl.
$ curl localhost:5984
If you are already using CouchDB for other things, we recommend starting a second instance of CouchDB that is completely separate from your original one. See below for instructions.
In this guide, we assume that your CouchDB is available at port 5984.
Create a CouchDB admin user called admin with a strong password of your choice at by clicking on the Fix this at Apache CouchDB-Futon:Overview link in the lower right corner. Use admin as username and keep your password in mind.
Next we have to change CouchDB’s default configuration on a few points. The easiest thing is to go to and change the following fields (double click a value to enter the editing mode):
couchdb -> delayed_commits: false couchdb -> max_dbs_open: 1024
Add this to
hoodie soft nofile 768 hoodie hard nofile 1024
Create a new system user:
$ sudo useradd --system \ -m \ --home /home/hoodie \ --shell /bin/bash \ --no-user-group \ -c "Hoodie Administrator" hoodie
This will create a new user and its home directory /home/hoodie. But unless you have a password, you can not be a user. To set a password run:
$ sudo passwd hoodie
Give a password of your choice.
cd in to that directory.
To switch to hoodie user, run:
$ sudo su hoodie
As user Hoodie, install your application:
$ git clone <repo url>
make sure package.json has a valid name property.
cd into the directory.Run :
$ cd <repo name>
$ npm install
To run Hoodie as the root:
$ sudo su hoodie
To launch Hoodie now, as root :
$ npm start -- --dbUrl=http://admin:yourpassword@localhost:5984/
yourpassword with the password you choose when you created the
admin user above.
That’s it. The app should be running by now.