Skip to content

Latest commit

 

History

History
138 lines (109 loc) · 5.88 KB

deployment.md

File metadata and controls

138 lines (109 loc) · 5.88 KB

Deployment

Deploy with now

now is a great way to quickly deploy Node.js applications. Unfortunately, now is a read-only file system, so you must either run your app in memory or set an external CouchDB URL.

Add this script to your package.json and you are good to go:

  "now-start": "hoodie --inMemory",

Alternatively, you can also set environment variables. If you set hoodie_inMemory=true it will have the same effect as the "now-start" script above. To set a CouchDB URL, set hoodie_dbUrl=https://admin:[email protected]

Deploy with Docker

Start CouchDB

$ docker run -d --name my-couchdb \
    -v /data/couchdb:/usr/local/var/lib/couchdb \
    klaemo/couchdb:1.6.1
$ # create a admin user with the password `secret`
$ # of course you can use you own username/password
$ docker run -it --rm \
    --link my-couchdb:couchdb \
    yxdhde/alpine-curl-git curl -X PUT \
    couchdb:5984/_config/admins/admin -d '"secret"'
$ # login with the admin user
$ docker run -it --rm \
    --link my-couchdb:couchdb \
    yxdhde/alpine-curl-git curl -X POST \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    couchdb:5984/_session -d 'name=admin&password=secret'

Build hoodie-app-tracker

$ docker build -t hoodie-app-tracker .
$ docker run -d -p 8080:8080 \
    --name my-app \
    --link my-couchdb:couchdb \
    hoodie-app-tracker
Or use the prebuilt Docker image
$ docker run -d -p 8080:8080 \
    --name my-app \
    --link my-couchdb:couchdb \
    -e hoodie_dbUrl=http://admin:secret@couchdb:5984/ \
    hoodiehq/hoodie-app-tracker

Continuous deployment with Docker Hub

$ docker run -d --name hub-webhook \
    -e VIRTUAL_HOST=webhook-deploy.my-domain.com \
    -e DEFAULT_PARAMS='--restart=always -p 8080:8080 --link my-couchdb:couchdb' \
    -e DEFAULT_TOKEN=my-webhook-token \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    christophwitzko/docker-hub-webhook

Set up a webhook on Docker Hub with the URL http://deploy-webhook.my-domain.com/my-webhook-token.

Example with a reverse proxy

This example is deployed at tracker.hood.ie.

Reverse Proxy with Letsencrypt

The following two docker commands start a Nginx reverse proxy with automatic certificate creation and renewal.

$ docker run -d -p 80:80 -p 443:443 \
    --name nginx-proxy \
    -v /data/certs:/etc/nginx/certs:ro \
    -v /etc/nginx/vhost.d \
    -v /usr/share/nginx/html \
    -v /var/run/docker.sock:/tmp/docker.sock:ro \
    jwilder/nginx-proxy
$ docker run -d --name letsencrypt-companion \
    --volumes-from nginx-proxy \
    -v /data/certs:/etc/nginx/certs:rw \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    jrcs/letsencrypt-nginx-proxy-companion

Start CouchDB