Heroku
Amber 0.7.2
isn't compatible with Crystal 0.25.0
Please use a .crystal-version
file with 0.24.2
instead
If you haven't done so please read the guides to install the Amber CLI
The Amber Heroku Buildpack
Based on Crystal Heroku Buildpack
You can create an app in Heroku with Amber buildpack by running the following command:
The default behaviour is to use the latest crystal release. If you need to use a specific version create a .crystal-version
file in your application root directory with the version that should be used (e.g. 0.23.1
).
Requirements
First of all you need to add Heroku addons: Heroku Redis
and Heroku Postgres
for created app. Then uncomment in config/settings.cr
:
In order for the buildpack to work properly you should have a shard.yml
file,as it is how it will detect that your app is a Crystal app. Your application has to listen on a port defined by Heroku.
In Amber versions less than or equal to 0.3.7 add the following code to your config/application.cr
file
To be able to decrypt and use production environment you'll need to set ENV["AMBER_ENCRYPTION_KEY"]
to the value of your local projects .encryption_key
file.
Never add .encryption_key
to github. Amber adds it by default to your .gitignore
file.
All that's left is to create a git repository, add the Heroku remote and push it there.
Using the Amber CLI on Heroku
When you deploy your project to heroku the amber build-pack will make available the amber cli
to you via the bin/amber
path.
To run an amber command just on heroku do the following:
Read more about heroku run
command on Heroku Dev Center
The Heroku Procfile
To deploy your app to heroku you're going to need a Procfile
. Create a Procfile at the root of your Amber application and add the following:
The Amber buildpack takes care of compiling the project for you but if you wish to run your project locally using the heroku command heroku local
you must do the following steps.
Create an .env
at the root of your Amber project and add the following 2 lines to the .env
Then you must compile your project locally with the following command:
crystal build src/{your-app-name}.cr -o bin/{your-app-name}
.
When the compilation process is complete a bin/{your-app-name}
directory is added, with this binary of your application with this binary file ready you can proceed to run your application locally with heroku.
And should output something similar to:
You're are now all set and ready to deploy with Heroku.
Last updated