-
Create an account on Heroku
-
Install Heroku CLI
-
Set up pgAdmin4
- Forget it; this tool is uggggh - just go with DataGrip instead.
- The project uses Go's new dependency management system.
- For details, see https://blog.golang.org/using-go-modules
- This walkthrough uses the general approach outlined in:
- https://devcenter.heroku.com/categories/go-support
- https://devcenter.heroku.com/articles/oauth2-heroku-go
- https://elements.heroku.com/addons
- Fork this GitHub repo: https://github.com/jdavid1234/chitchat
- Clone it down to your local machine.
- Do search (from top dir in repo) for
jdavid1234
and change to your GitHub account name.
- Run
go test
- Run
go mod tidy
(cleans up unused dependencies). - Check
go.mod
andgo.sum
files to ensure all looks good. go list -m all
heroku create
- This creates a new empty application on Heroku, along with an associated empty Git repository. If you run this command from your app’s root directory, the empty Heroku Git repository is automatically set as a remote for your local repository.
git remote -v
git push heroku master
- Note, the file
Procfile
tells Heroku which command(s) to run to start your app.
Add a free Heroku Postgres Starter Tier dev database to your app:
heroku addons:create heroku-postgresql:hobby-dev
Show the $DATABASE_URL
environment variable:
heroku config
Heroku also provides a pg
command that shows a lot more:
heroku pg
- Add a
.env
file. - Note, this file is intentionally in
.gitignore
- Run
heroku config
to get the Heroku app name - Open that app on your Heroku dashboard: https://dashboard.heroku.com/apps
- Open the PostgreSQL add-on for that app.
- View Credentials on the Settings app.
- Create connection in pgAdmin4 using that info.
- Using pgAdmin run the
data/setup.sql
script.
- Note this will be the general flow for working with Git now that we have Heroku remote as well.
go mod tidy
go mod vendor
git status
git add --all
git commit -a -m 'Initial launch'
git push heroku master
# Push to GitHub as well:
git push origin master
As a handy shortcut, you can open the website as follows:
heroku open
View information about your running app:
heroku logs --tail
go build -o bin/chitchat -v .
- Start your app locally using the
heroku local
command.- This is installed as part of the Heroku CLI.
- Just like Heroku, it examines the
Procfile
to determine what to run.
heroku local web
- Open http://localhost:8080 with your web browser.
- To stop the app from running locally, go back to your terminal window and press
Ctrl+C
to exit.
Note the glossary:
Approach taken here is based on:
- https://devcenter.heroku.com/articles/custom-domains
- https://medium.com/@ethanryan/setting-up-a-custom-domain-for-your-heroku-hosted-app-6c011e75aa3d
- Buy a custom domain name (I used name.com)
- Example used below is for domain
davidforum.com
heroku domains:add www.davidforum.com
heroku domains:wait 'www.davidforum.com'
Note the output; configure your app's DNS provider to point to the DNS Target:
integrative-kiwi-i8a0bariil1ahajauz37x4n6.herokudns.com
heroku domains:add davidforum.com
heroku domains:wait 'davidforum.com'
Note the output, configure your app's DNS provider to point to the DNS Target:
still-sprout-wdcdz1tpzkyitakes8rs9x7z.herokudns.com
- Add the DNS Records in name.com (or whatever site you bought your domain on).
View existing domains:
heroku domains
... Now wait a few minutes ...
NOT NEEDED YET:
- Set your config variables on Heroku.
- Note,
$PORT
is automatically set by Heroku on web dynos - so don't set that one.
heroku config:set REPEAT=10