No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
db
public
views
.gitignore
Procfile
app.json
container.md
heroku.yml
package.json
readme.md
web.js
worker.js

readme.md

ASCIIfy

This project demonstrates a non-trivial app with container-build.

Quick Start

  • Install Docker
  • Check that docker is available in your terminal (docker ps)
$ heroku plugins:install container-build
$ git clone https://github.com/heroku-examples/node-asciify.git
$ cd node-asciify
$ heroku create
$ heroku addons:create heroku-redis
$ heroku addons:create heroku-postgresql
$ heroku _container:build
$ heroku _container:run --config

Now open http://localhost:5000.

Then, in a new terminal:

$ cd node-asciify
$ heroku _container:run --type worker --config

Now, you have two local dynos running: web and worker. Your local server should be able to turn images into ASCII art.

Test some images:

Deploy

Once you're done working locally, deploy to Heroku:

$ heroku _container:build
$ heroku _container:push
$ heroku scale worker=1
$ heroku open

All the Moving Parts

ASCIIfy is composed of four parts and is intentionally modular to illustrate how Heroku-Docker helps manage complexity:

  • web (node.js)
  • worker (node.js)
  • postgres (db - processed images)
  • redis (queue - pending images)
  • graphicsmagick (custom binary)

ASCIIfy also needs graphicsmagick, which isn't built into Heroku's Cedar-14 stack. We extend the stack to support the app by adding the dependency to heroku.yml.

Compared to a standard deploy

Try this with a new Heroku app:

$ git remote rm heroku
$ heroku create
$ heroku addons:create heroku-postgresql
$ heroku addons:create heroku-redis
$ git push heroku master
$ heroku scale worker=1
$ heroku open

This app will never process images because the worker crashes when trying to locate graphicsmagick.

Compared to a Dockerfile deploy

In order to deploy this with a Dockerfile, you'll need to first write an appropriate Dockerfile.

Then you'll need to use Docker locally to build the image, then tag the image, then push the image to Heroku's container registry.

From then on, you'll have to maintain the runtime, npm version, security, etc based on the Dockerfile you've written.

Good luck!