Deployment is an extremely important part of the process, but one that most developers dread because it falls outside the developer's core business and into that of devops.

Build your bot app

The principal aim of Mineral is to simplify the developer experience. That's why we've created a simple command to build your application and create an executable. This executable is a single file that you can deploy anywhere, without having to worry about dependencies or other configuration. Besides, this allows you to share only the executable with your customers and not all the source code.

To build your application, you just have to run the following command at the root of your project.

dart run mineral compile:exe

Dart creates an executable for your operating system. If you build on Windows, you will receive a Windows executable which doesn't work on Linux.

Deploy your executable

With pm2

PM2 is a process manager based on NodeJS. It allows you to keep your application running in the background and to restart it automatically in case of a crash. To use it with your executable, you just have to run the following command.

pm2 start <your executable file>

If your bot doesn't start, check if the executable has the right to run.


Docker is a powerful cross-platform containerisation tool that is widely used in the professional world.

Before starting a deployment with Docker, please refer to the official documentation to ensure that your installation is correct.


Now that your installation is done, we will create a Dockerfile at the root of our project with the following information.

In our instructions we use the official Docker image of the Dart language.

FROM dart:stable AS build

COPY pubspec.* ./
RUN dart pub get

COPY . . 
RUN dart pub get --offline
RUN dart compile exe ./src/main.dart -o ./mineral

# --

FROM scratch
COPY --from=build /runtime /
COPY --from=build /app/mineral /app/

CMD ["/app/mineral"]

In the first part, we build our application with the dart compile command. This command will create an executable in the ./app directory. In the second part, we rebuild a new image from scratch to reduce the size of our image. We copy the executable from the previous state and we define the command to run when the container starts.

Starting using Docker CLI

Now that the Docker image is configured, all we have to do is build it with the following command and then start it.

# Build the image
docker build -t <name>:latest .

# Starting our application
docker run -d --name <display name> <name>

Starting using Docker Compose

Docker Compose is a tool that allows you to manage multiple containers at the same time. It can be very useful if you want to deploy your application with a database for example.

To use it, you just have to create a docker-compose.yml file at the root of your project with the following information.

version: "3.8"

    build: .
      APP_TOKEN: "<your token>"
      LOG_LEVEL: info
      DEBUGGER: false
    restart: always

Then you just have to run the following command to start your application.

docker compose up -d

Congratulations, you have just deployed your first Discord application ! 🎉

Shared states