Dokku
Requirements
Before getting started, ensure you have a Dokku instance running with a new app. An example app can be created following these steps:
Define Buildpack
Buildpacks tell Dokku how to build and deploy your application. Create a file named .buildpacks
in the root of your project and with this:
If you want js / css to be compiled, you need to modify the build
command in package.json
to "build": "npm run release",
. Because the nodejs buildpack expects npm build
to compile the production assets.
Not defining a .buildpack file will cause Dokku to build your project using the Dockerfile
as Dokku will auto-detect it, this will not work and cause issues.
Define Crystal Version
It's best practice to lock your crystal version to the one you're using. Without this the latest version of crystal will be used, potentially causing issues in deployment.
Create a file named .crystal-version
in the root of your project with the wanted crystal version:
Create Procfile
To deploy your app to Dokku 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.
Env Vars
Set Production Vars
Where ever your application runs, it needs to be in production mode.
Set Encryption Key
Ensure you first run:
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.
Copy the key from .encryption_key
and set it to env, like so:
Pick up Env vars
In order for the buildpack to work properly your application has to:
Listen on the environment's port.
Connect to any services like redis / database.
Ensure these settings are in your settings.cr
file.
Deploying
All that's left is to create a git repository, add the Dokku remote and push it there.
More information on how to deploy your app can be found on the Dokku docs
Last updated