AdonisJS was one of my very first NodeJS frameworks back in the day. Recently I took some time to add improved support to it on our fly launch
process.
Here’s what you need to deploy an AdonisJS app with postgres:
-
fly launch
on your app folder and accept creating a new Postgres DB. - Add this to your fly.toml
[deploy]
release_command = "/app/docker-entrypoint.js node ace migration:run --force"
fly deploy
That’s it!
A note on AdonisJS
For testing, I also used a default-generated project and turns out it failed npm run build
by default because of a single warning so before deploying you’d want to check if your typescript project compiles.
Another possible source of headaches is env.ts
. This will generate errors at runtime if there’s missing variables. We will already set the envs below for you but if you have some extra (say a custom environment variable) you’d want to check how to add [env] to your fly.toml or how to use secrets before you deploy.
APP_KEY
HOST
PORT
CACHE_VIEWS
SESSION_DRIVER
DRIVE_DISK
DB_CONNECTION
PG_HOST
PG_PORT
PG_USER
PG_PASSWORD
PG_DB_NAME
As for file uploads, if needed, you’d want to use an object storage in case you want your app to scale horizontally or if you’re fine with a single stance AdonisJS app, feel free to setup volumes on /app/tmp/uploads
See you next time!