Skip to main content
To learn more about TypingMind Team Self-host version, visit https://custom.typingmind.com/self-host

Installation Instructions

To setup a self-host instance, you will need the following:
  1. A server that support Docker.
  2. MySQL 8.x for storing data.
  3. An SMTP credential for sending emails.

Step 1: Prepare a MySQL database

Use any database hosting provider that support MySQL 8.x. Requirements:
  • MySQL 8.x
  • At least 1 dedicated CPU
  • At least 4GB of RAM
After the database is up and running, take note of the database credentials for later steps.

Step 2: Prepare SMTP credentials

The self-host instance uses SMTP to send emails (i.e., login OTP). You can use any SMTP provider. The only requirement is that it must support secure email transport (TLS) via port 465 or 587. If you are using a self-signed certificate for your SMTP server, you need to set the SMTP_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to 1.

Step 3: Prepare Environment Variables

Before going to the next step, make sure you have all of these environment variables ready. Hostname: the hostname where you intend to deploy the app to.
Database: enter your MySQL credentials in connection string format as below. Make sure to include the paramaters (ssl, timezone,namedPlaceholders), in the connection string as shown below.
If you’re using SSL connection for MySQL: (--require_secure_transport=ON.), add ssl={"rejectUnauthorized":true} to the URL parameter. Then add this additional environment variable:
If you are using planetscale.com as your database, add this additional variable so that the app use an appropriate database engine that supported by PlanetScale:
Instance info. Will be shown in various places in the app.
SMTP credentials. Used for sending OTP emails when users login. Make sure the SMTP server is configurated and authorized to send emails using the APP_CLOUD_EMAIL_DOMAIN hostname, otherwise, emails may land in users’ Spam folder.
Note: if you are using a self-signed certificate for your SMTP server, you need to set the SMTP_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to 1.
User-provided endpoints. To safeguard against internal network exposure, all internal endpoints (e.g., IP addresses, localhost) are blocked by default for resources like custom models, plugins, and agents. If necessary, you can override this restriction by setting the ALLOW_UNSAFE_USER_ENDPOINTS environment variable to 1.
Other mandatory variables. Cookie secrets is used to sign data in cookies, you can generate it yourself or just use a random string. Instance key is provided to you as part of your purchase.

Step 4: Deploy with Docker

Connect this repository to your hosting provider to start the deployment. Here are some relevant details to help you with the setup: Hardware requirements:
  • At least 1 dedicated CPU
  • At least 4GB of RAM
Our official docker image is hosted at ghcr.io/typingmind/tm-self-host:latest. To run the docker image, use the following command (change the 12151 port and the environment variables to your own):

Step 5: Verify your deployment

The HTTP server will run on the specified port number based on the PORT environment variable set by your hosting provider. To verify that the app is running properly, send a request to the HTTP server (by visiting the hostname URL). If the request hit the server, you will see this log in the server’s output:
When you first open the app, you will be redirected to /setup URL to set up your instance.

Receiving Updates

To receive new updates, pull the docker image again from our official registry at ghcr.io/typingmind/tm-self-host:latest Changelog can be viewed from the Admin panel or you can see it online here: https://www.typingmind.com/changelog

Blob Storage

Blob Storage module is required if you want to use attachments features (upload images, files, documents). TypingMind can be connected to a S3-compatible bucket for better storing files. When connected, TypingMind will use the S3-compatible bucket for storing various files during its operation like user chat attachments, admin-user uploaded files, support faster user data sync, and other purposes. To connect the app to a S3-compatible bucket, set the following environment variables:
Your S3-compatible storage provider must support at least the the following features from S3:
  • Standard object operation: HeadObject, ListObjects, GetObject, PutObject, DeleteObject.
  • Signed requests: GET and PUT.
  • CORS configuration that allow TypingMind to call the service API from the browser.
Below is an example CORS configuration for Cloudflare R2:
By default, TypingMind assume the blob storage end point is reachable from public internet, so some attachments are sent as pre-signed URLs directly to the AI models. If your blob storage is only reachable from internal network, you need to set the following environment variable:
When this variable is set, TypingMind will send attachments as Base64 URL, which is slower and less efficient.

Optional modules

Enable metrics tracking

Metrics tracking can be enable by setting the DB_TRACK_METRICS:
When enabled, related metrics will be collected in the tbl_metrics table in your database and can be synced to your data warehouse for analytics. The metric payload is a schema-less JSON object contains useful information like: token usage, user, AI agent used, etc.

Enable background cron jobs

Cron jobs are required for some features like sending daily/weekly report emails, cleaning up expired data, etc. To enable cron jobs, set the CRON_SECRET environment variable to a secure secret string.
If you are running multiple instances of the server, make sure to only enable cron jobs on only one server instance to avoid duplicated cron jobs.

Custom SMTP email settings

Use SMTP_SENDER_ADDRESS to customize the sender address of the email sent by the app. By default, it uses no-reply@${APP_CLOUD_EMAIL_DOMAIN}.
Use DISABLE_SMTP_SECURE to disable secure connection to SMTP server. This is useful in some cases where your SMTP server needs the connection to be created on insecure mode then upgrade to secure mode at a later step.

Knowledge Base

Knowledge Base is an optional module that provide RAG (retrieval-augmented generation) processing pipeline TypingMind. This module can only be enabled when:
  • You are using the pre-built TypingMind Docker image provided above.
  • Your TypingMind instance must be served over secure HTTPS connection.
To enable this module, add the following environment variable:
TypingMind uses embedding models from OpenAI, so the OPENAI_API_KEY is used to access the OpenAI API. The PG_DATABASE_URL is a connection strings to a PostgreSQL database with the following requirements:
  • PostgreSQL version 16.x
  • Must support pgvector extension for storing vector embeddings.
  • At least 1 dedicated CPU, recommended at 2 dedicated CPUs.
  • At least 4GB of RAM, recommended at 8GB of RAM.
  • At least 30GB of storage space, recommended at 100GB of storage space.
After setting up the environment variables, restart the docker container and go to Admin Panel → Knowledge Base to set up the Knowledge Base module.

Example deployment with docker compose

Below is an example docker-compose.yml file that you can use to deploy TypingMind with Docker Compose with minimal environment variables set.
This example docker-compose.yml file will create 4 services, including the Blob Storage module. You can run this file by running the following command in the same directory as the file:

Changelog

Changelog can be viewed from the Admin panel, or you can see it here: https://www.typingmind.com/changelog

User Guide / Documents

Visit our webpage for user guides and documents on how to utilize all features of TypingMind. https://docs.typingmind.com/