【Heroku】How to install service and setup environment variable: Use Tesseract OCR as example

Zam Huang
2 min readFeb 26, 2020

--

Brief

This is going to lead you to use apt to install service, and setup environment variable.

First - Add apt buildpack into Heroku

The apt buildpack:

All buildpacks in Heroku

On Command-line

To use the latest stable version:

heroku buildpacks:add --index 1 heroku-community/apt

To use the edge version (i.e. the code in this repo):

heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

On Web:

The web link: https://dashboard.heroku.com/apps/{app_name}/settings

Click “add buildpack”

Add buildpack

enter buildpack url

enter buildpack url

Second - Create “Aptfile” in your app

echo "tesseract-ocr\ntesseract-ocr-eng" >> Aptfile

Third - Set TESSDATA_PREFIX

You have to enter bash and check the tesseract path, and find our target “eng.traineddata path”

heroku run bash~ $ which tesseract
/app/.apt/usr/bin/tesseract
~ $ ls /app/.apt/usr/share/tesseract-ocr/4.00/tessdata/
configs eng.traineddata osd.traineddata pdf.ttf tessconfigs

On Command-line

To use the latest stable version:

heroku config:set TESSDATA_PREFIX=/app/.apt/usr/share/tesseract-ocr/4.00/tessdata

To use the edge version (i.e. the code in this repo):

heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

On Web:

The web link:https://dashboard.heroku.com/apps/{app_name}/settings

Add the environment

If you like this one or feel helpful, please applause or follow to Zam, I am really appreciate you doing that

--

--

Zam Huang
Zam Huang

Written by Zam Huang

一個記錄著自己人生過程的工程師。A Software Engineer at Ruckus Network in Taiwan。 IG, Linkedin:@zam_huang, stack overflow: user:2613194

No responses yet