How can I deploy my Hexabot Project?
Introduction
This documentation explains how to deploy your Hexabot project using two different methods:
Pre-requisites
Make sure you have access to a server running a Linux distribution with SSH enabled. The following documentation is based on an Ubuntu distribution, so you may need to adapt the steps according to your specific operating system.
Using Nginx as a service and Certbot for SSL
Step 1: Install Docker
Setting Up Docker for Development and ProductionStep 2: Install NPM
Setup Node.js with NVMStep 3: Setup Hexabot project
Install the Hexabot CLI:
Create new project:
Or clone an existing project of yours:
Environment Setup:
To configure the environment variables, use the following command:
This command will copy the .env.example
file to .env
in the ./docker
directory if the file does not already exist
Update your
.env
file for production, especially the following ones:
Variable Name | Example Value | Env variable description |
---|---|---|
NODE_ENV | prod | Environment Mode |
APP_DOMAIN | mychatbot.ai | Application Domain Name |
API_ORIGIN | https://mychatbot.ai/api | The api endpoint will be used to communicate with the backend |
FRONTEND_ORIGIN | https://mychatbot.ai | The origins that will be accepted by the API |
JWT_SECRET | 346998ba1f171f107433 | Secret to encrypt jwt token |
SESSION_SECRET | 27feaf70d2c78892bf49 | Secret to encrypt session token |
HTTPS_ENABLED | true | Https setting |
INVITATION_JWT_SECRET | 51c8ea00d82eb10ee226 | Secret to encrypt invitation token |
PASSWORD_RESET_JWT_SECRET | 5ee97916017176d1ca6c | Secret to encrypt reset password token |
CONFIRM_ACCOUNT_SECRET | 80f74dce70e5385bf80b | Secret to encrypt confirm account token |
MONGO_USER | my_mongo_username | Mongodb username |
MONGO_PASSWORD | my_mongo_password | Mongodb password |
AUTH_TOKEN | c97643c1c1e5e9dc5745 | Secret to encrypt NLU token |
NEXT_PUBLIC_API_ORIGIN | https://mychatbot.ai/api | Nextjs api endpoint |
Note that you can also adjust the default token expirations durations as needed.
To be able to send email you will need to configure SMTP. Learn how to configure SMTP environment variables by following our detailed SMTP setup guide.
Run your Hexabot project in production mode:
Note that this command will start all the services (api, frontend, mongodb, ...) as Docker containers.
Step 4: Install Nginx
Deploying an Hexabot project on production requires you to setup a HTTP Web Server like Apache2, HAProxy or Nginx to secure communications using SSL, establish access per domain name, and a lot of other capabilities such as rate limiting for example to help protect against abuse and prevent server overload. In this guide, we will walk you through a typical HTTP Web Server setup using Nginx and Certbot for SSL certificate generation.
Update the system:
Install Nginx:
Verify the Nginx installation:
Start Nginx:
Check the Nginx status:
Step 5: Configure Nginx
Replace Nginx server configuration with the following : /etc/nginx/sites-available/default.
Step6: Generate SSL certificate using Certbot
Install Certbot:
Obtain an SSL certificate:
(Optional) Automate SSL renewal:
Add the following line:
Step 7: Reload Nginx with new configuration
Test configuration syntax:
If you get an error please make sure you don't have any syntax error in /etc/nginx/sites-available/default
Reload Nginx with new configuration:
Access your domain using HTTPS (eg. https://mychatbot.ai) to check if you have successfully deployed your Hexabot project using Nginx! 🚀🎉. Feel free to ask for support from the community on our Discord channel.
Using Dockerized Nginx and Certbot services :
The second deployment method, where everything is Dockerized, is still WIP.
Last updated