Alexis Bouchez

Deploying an AdonisJS application to



This guide is based on my experience deploying AdonisJobs to production on is a great platform for deploying Docker images. It's easy to setup and has a useful dashboard for managing your application.


Before you begin, you should have the following:

  • a account, if you don't have one, you can sign up for free here ;
  • a working AdonisJS application.

Install the Fly CLI

The Fly CLI is a command-line tool that allows you to deploy your application to You can install it by running the following command:

curl -L | sh

Login to Fly

After installing the Fly CLI, you can login to Fly by running the following command:

fly auth login

Dockerize your application deploys your application as a Docker container. So, you need to create a Dockerfile for your application. You can create a Dockerfile by running the following command:

touch Dockerfile .dockerignore

Then, add the following content to the Dockerfile:

ARG NODE_IMAGE=node:16.13.1-alpine

RUN apk --no-cache add dumb-init g++ make py3-pip
RUN mkdir -p /home/node/app && chown node:node /home/node/app
WORKDIR /home/node/app
USER node
RUN mkdir tmp

FROM base AS dependencies
COPY --chown=node:node ./package*.json ./
RUN npm ci
COPY --chown=node:node . .

FROM dependencies AS build
RUN node ace build --production

FROM base AS production
ENV NODE_ENV=production
COPY --chown=node:node ./package*.json ./
RUN npm ci --production
COPY --chown=node:node --from=build /home/node/app/build .
CMD [ "dumb-init", "node", "server.js" ]
# Adonis default .gitignore ignores

# Additional .gitignore ignores (any custom file you wish)

# Additional good to have ignores for dockerignore

Create a Fly application

After creating a Dockerfile, you can create a Fly application by running the following command:

fly apps create <app-name>

Set up your database uses PostgreSQL as the default database. You can create a PostgreSQL database by running the following command:

fly databases create <db-name>

Set up your environment variables uses secrets to configure your application. You can set up your environment variables by running the following command:

fly secrets set PORT=3333 NODE_ENV=production APP_KEY=<app-key> DB_CONNECTION=pg DB_HOST=<db-host> DB_PORT=<db-port> DB_USER=<db-user> DB_PASSWORD=<db-password> DB_DATABASE=<db-name>

Deploy your application

After setting up your environment variables, you can deploy your application by running the following command:

fly deploy

Run migrations

fly ssh console -C "node ace /home/node/app/build/ace migration:run"

Launch your application

After deploying your application, you can launch it by running the following command:

fly launch


In this guide, you learned how to deploy an AdonisJS application to

If you have any questions, feel free to reach me.

Don't forget to follow me on Twitter @alexisbcz for more content like this.