Installing heroku on Unix/Linux

Heroku is platform as a service (PaaS) that simplifies deploying your applications on the Internet.

Installing heroku on Linux

You should install snap and then execute:

$ sudo snap install heroku --classic

Can juzat….

Installing heroku on MacOS

For a start, you should put HOMEBREW:

Installing homebrew on MacOS

You can search for the package:

$ brew search heroku
==> Formulae
heroku/brew/heroku ✔ heroku/brew/heroku-node ✔

Put the package:

$ brew install heroku/brew/heroku

For upgrade, use:

$ heroku update

You can get to work.

Work with heroku in Unix/Linux

Of course, to use this service, you will need a account. I already have it, open the browser and perform the login.

For a start, you should create aplikasi. The page looks like this:

Click on “Create new app” to create your first app in shiroku. Is to fill in all the required fields, for example I have is as follows:

Where:

  • App Name — your app Name.
  • Choose region — choose a region where diploidy of aplikasi. I chose Europe, you can still use US.
  • The pipeline Name — the Name for my pipline.
  • Choose a stage to add this app to — Select stage ( production or staging).

After filling all fields, click on “Create app”. Application — ready.

The first thing you need to do is enter heroku:

$ heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/browser/bfc26cce-xxxx-xxxx-xxxx-63a3adf44bd3
Logging in... done
Logged in as [email protected]

Deploy python projects Heroku

Go to an existing directory ( where will lie all the projects):

$ cd my-project

Downloadable project:

$ git clone https://github.com/heroku/python-getting-started.git && 
cd python-getting-started

Inicijaliziram project:

$ git init

Then execute:

$ heroku git:remote-a go-captain-app

Create an Appendix on Heroku, which will prepare Heroku to getting your source code:

$ heroku create
Creating app... done, ⬢ shielded-tundra-23030
https://shielded-tundra-23030.herokuapp.com/ | https://git.heroku.com/shielded-tundra-23030.git

To expand applikasi is to perform:

$ git push heroku master
Enumerating objects: 450, done.
Counting objects: 100% (450/450), done.
Delta compression using up to 8 threads
Compressing objects: 100% (198/198), done.
Writing objects: 100% (450/450), 75.48 KiB | 25.16 MiB/s, done.
Total 450 (delta 225), reused 450 (delta 225)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.7.3
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting django (from-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 1))
remote: Downloading https://files.pythonhosted.org/packages/eb/4b/743d5008fc7432c714d753e1fc7ee56c6a776dc566cc6cfb4136d46cdcbb/Django-2.2.2-py3-none-any.whl (7.4 MB)
remote: Collecting gunicorn (from-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 2))
remote: Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB)
remote: Collecting django-heroku (from-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 3))
remote: Downloading https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
remote: Collecting sqlparse (from django->-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 1))
remote: Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
remote: Collecting pytz (from django->-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 1))
remote: Downloading https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl (510kB)
remote: Collecting whitenoise (from django-heroku->-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 3))
remote: Downloading https://files.pythonhosted.org/packages/fd/2a/b51377ab9826f0551da19951257d2434f46329cd6cfdf9592ea9ca5f6034/whitenoise-4.1.2-py2.py3-none-any.whl
remote: Collecting psycopg2 (from django-heroku->-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 3))
remote: Downloading https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz (377kB)
remote: Collecting dj-database-url>=0.5.0 (from django-heroku->-r /tmp/build_5e43415b11d8710488762f17cac3f792/requirements.txt (line 3))
remote: Downloading https://files.pythonhosted.org/packages/d4/a6/4b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d/dj_database_url-0.5.0-py2.py3-none-any.whl
remote: Installing collected packages: sqlparse, pytz, django, gunicorn, whitenoise, psycopg2, dj-database-url, django-heroku
remote: Running setup.py install for psycopg2: started
remote: Running setup.py install for psycopg2: finished with status 'done'
remote: Successfully installed dj-database-url django-0.5.0-2.2.2 django-heroku-0.3.1 gunicorn-19.9.0 psycopg2-2.8.3 pytz-2019.1 sqlparse-0.3.0 whitenoise-4.1.2
remote:
remote: -----> $ python manage.py collectstatic --noinput
remote: 120 static files copied to '/tmp/build_5e43415b11d8710488762f17cac3f792/staticfiles', 378 post-processed.
remote:
remote: -----> Discovering process types
remote: Procle declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 55.5 M
remote: -----> Launching...
remote: Released v5
remote: https://go-captain-app.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/go-captain-app.git
 * [new branch] master -> master

NOTE: For existing repositories, just add a remote reference:

$ heroku git:remote-a go-captain-app

So I have vrishni the account, I don’t know how many stayed with me hours to use the platform to test, you can use:

$ heroku ps --app go-captain-app
Free dyno hours quota remaining this month: 550h 0m (100%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping

=== web (Free): gunicorn gettingstarted.wsgi --log-file - (1)
web.1: up 2019/06/20 12:09:17 +0300 (~ 38s ago)

The app is now deployed. Make sure that at least one instance of the application running:

$ heroku ps:scale web=1
Scaling dynos... done, now running web at 1:Free

To see what happened, execute:

$ heroku open

Or, you can simply go to the URL:

https://YOUR_APP_NAME_HERE.herokuapp.com/

where:

  • YOUR_APP_NAME_HERE — name aplikasinya (created at the beginning of the article).

You can see the deployment logs:

$ heroku logs -t --app go-captain-app
2019-06-19T11:21:30.933892+00:00 app[api]: Release v1 created by user [email protected]
2019-06-19T11:21:30.933892+00:00 app[api]: Initial release by user [email protected]
2019-06-19T11:21:31.594682+00:00 app[api]: Enable Logplex by user [email protected]
2019-06-19T11:21:31.594682+00:00 app[api]: Release v2 created by user [email protected]
^C

Or:

$ heroku logs --tail

The app works and if there is a need to turn it off, you can do:

$ heroku ps:scale web=0
Scaling dynos... done, now running web at 0:Free

Run Django applications locally (for example I use above)

In downloaded other to be performed:

$ pip3 install-r requirements.txt

NOTE: I Will be using Python 3. Before you use this command, you need to put postgresql. I have everything on this come before I can finish.

To start, execute:

$ heroku local web

To open aplikeyshen, go to:

http://localhost:5000/

If necessary push the local chency on heroku, you should perform several steps:

$ git add . && 
git commit-m "commit from local changes" && 
git push heroku master

In fact, open then app.

Deployment Golang projects on Heroku

Go to an existing directory ( where will lie all the projects):

$ cd my-project

Downloadable project:

$ git clone https://github.com/heroku/go-getting-started.git && 
cd go-getting-started

Create an Appendix on Heroku, which will prepare Heroku to getting your source code:

$ heroku create
Creating app... done, ⬢ safe-coast-81222
https://safe-coast-81222.herokuapp.com/ | https://git.heroku.com/safe-coast-81222.git

Pushin the whole thing to heroku:

$ git push heroku master

Open URL or:

$ heroku open

That’s all with Go applications.

Installing Addons for Heroku

To see a list of add-ons, run:

$ heroku addons

Add-on Plan Price State
───────────────────────────────────────────────── ───────── ───── ───────
heroku-postgresql (postgresql-asymmetrical-97337) hobby-dev free created
 └─ as DATABASE

The table above shows the add-ons and the attachments to the current app (go-captain-app) or other apps.

For example, to put papertrail, run:

$ heroku addons:create papertrail

Look what happened:

$ heroku addons:open heroku-postgresql

Or example for papertrail:

$ heroku addons:open papertrail

Starting SHELL in Heroku

To get a shell, run:

$ heroku run bash
Running bash on ⬢ go-captain-app... up, run.6043 (Free)
~ $

If we consider the example in Python ( that I yuzal above), you can do:

$ heroku run python manage.py shell
Running python manage.py shell on ⬢ go-captain-app... up, run.8036 (Free)
Python 3.7.3 (default, Apr 3 2019, 21:35:17)
[7.3.0 GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>

Thereby, get access to Python.

Set the environment variables in Heroku

To add peremennoy, use:

$ heroku config:set TIMES=2
Setting TIMES and restarting ⬢ go-captain-app... done, v6
TIMES: 2

To view a list of all variables, use:

$ heroku config
=== go-captain-app Config Vars
DATABASE_URL: postgres://wlcnujaybqtbnx:4[email protected]ec2-54-246-121-32.eu-west-1.compute.amazonaws.com:5432/d5f7acvu6m7dvl
TIMES: 2

Work database in Heroku

Look at what is available:

$ heroku addons

Add-on Plan Price State
───────────────────────────────────────────────── ───────── ───── ───────
heroku-postgresql (postgresql-asymmetrical-97337) hobby-dev free created
 └─ as DATABASE

The table above shows the add-ons and the attachments to the current app (go-captain-app) or other apps.

As seen from terminal a — postgresql.

Look environment variables:

$ heroku config
=== go-captain-app Config Vars
DATABASE_URL: postgres://wlcnujaybqtbnx:4[email protected]ec2-54-246-121-32.eu-west-1.compute.amazonaws.com:5432/d5f7acvu6m7dvl

Heroku also provides a command pg, which shows much more information:

$ heroku pg
=== DATABASE_URL
Plan: Hobby-dev
Status: Available
Connections: 0/20
PG Version: 11.2
Created: 2019-06-20 09:09 UTC
Data Size: 7.7 MB
Tables: 0
Rows: 0/10000 (In compliance)
Fork/Follow: Unsupported
Rollback: Unsupported
Continuous Protection: Off
Region: Europe
Add-on: postgresql-asymmetrical-97337

To connect to a remote database server, use:

$ heroku pg:psql
--> Connecting to postgresql-asymmetrical-97337
psql (11.3, 11.2 server (Ubuntu 11.2-1.pgdg16.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

go-captain-app::DATABASE=>

That’s all, “Install heroku Unix/Linux” is completed.

Source: linux-notes.org

(Visited 50 times, 1 visits today)