Self Hosting
Kommentar is built to be self-hostable first and foremost. Running Kommentar on your own server gives you full control over your data and the environment.
As long as you do not change anything in the database schema, or the code, Kommentar can be upgraded without data loss.
Before moving forward, make sure you have cloned the Kommentar repository from GitHub:
# Via HTTPSgit clone https://github.com/kommentar/kommentar.git
# Via SSH
This guide is split into two sections:
- Getting Kommentar up and running on your server (Setup with Docker)
- Upgrading Kommentar (Upgrading)
Setup with Docker
Section titled “Setup with Docker”Kommentar can be setup on any server easily using Docker. This is the recommended way to run Kommentar in production.
Prerequisites
Section titled “Prerequisites”- Docker installed on your server. Instructions can be found in Docker’s official documentation.
- Docker Compose installed on your server, if you choose to use it. It’s what I personally recommend. You can find instructions in Docker’s official documentation.
- A valid
.env
file in the root directory of the Kommentar repository. This file contains environment variables that Kommentar needs to run. You can find an example.env.example
file in the repository, which you can use as a template to create your own.env
file.
With Docker Compose Recommended
Section titled “With Docker Compose ”You can use the provided docker-compose.yaml
file to run Kommentar with Docker Compose. This file is located in the root directory of the Kommentar repository.
docker-compose up -d# ORdocker compose up -d
This command will start Kommentar in detached mode, meaning it will run in the background.
You can then access Kommentar at http://localhost:3000
or the IP address of your server.
Post Setup
Section titled “Post Setup”Verify that the Kommentar container is running:
docker ps
You should see a container named kommentar-app-1
or similar, depending on your Docker Compose configuration.
Now is a good time to set up the admin user for Kommentar. You can do this by following these steps:
-
Run the Kommentar
setup:admin
script to create the admin user:Terminal window docker exec -it kommentar-app-1 pnpm setup:adminThis will generate all the credentials for the admin user. The output will look like this:
🔐 Admin credentials generated!Add these to your environment variables:ADMIN_KEY=km_f0b0633329feb55f43344d92d7361776ADMIN_SECRET_HASH=8162ab4d6fc4c54270634d5bfaf8e2e45835313568b85a23888fb0ecde46a0e8⚠️ IMPORTANT: Save the plain secret below - it won't be shown again!Admin API Secret (plain): 81a6fa20c25747dd3230aac84f0a47a85a25562677e2313471f3e8f9316dd158🔄 Remember to restart your server after setting the environment variables! -
Copy the values of
ADMIN_KEY
andADMIN_SECRET_HASH
to your.env
file. This is important for the admin user to be able to access Kommentar’s API. Make sure to store the Admin API Secret (plain) in a secure place, as it will not be shown again, and is needed when sending requests to Kommentar’s API. -
Restart the Kommentar container to apply the changes:
Terminal window docker-compose restart# ORdocker compose restart
Without Docker Compose
Section titled “Without Docker Compose”If you prefer to run Kommentar without Docker Compose, you can do the following:
-
Build the Docker image:
Terminal window docker build -t kommentar . -
Run the Kommentar container:
Terminal window docker run -d --env-file .env --name kommentar -p 3000:3000 kommentar
Post Setup
Section titled “Post Setup”Verify that the Kommentar container is running:
docker ps
You should see a container named kommentar
or similar, depending on your Docker configuration.
Now is a good time to set up the admin user for Kommentar. You can do this by following these steps:
-
Run the Kommentar
setup:admin
script to create the admin user:Terminal window docker exec -it kommentar pnpm setup:adminThis will generate all the credentials for the admin user. The output will look like this:
🔐 Admin credentials generated!Add these to your environment variables:ADMIN_KEY=km_f0b0633329feb55f43344d92d7361776ADMIN_SECRET_HASH=8162ab4d6fc4c54270634d5bfaf8e2e45835313568b85a23888fb0ecde46a0e8⚠️ IMPORTANT: Save the plain secret below - it won't be shown again!Admin API Secret (plain): 81a6fa20c25747dd3230aac84f0a47a85a25562677e2313471f3e8f9316dd158🔄 Remember to restart your server after setting the environment variables! -
Copy the values of
ADMIN_KEY
andADMIN_SECRET_HASH
to your.env
file. This is important for the admin user to be able to access Kommentar’s API. Make sure to store the Admin API Secret (plain) in a secure place, as it will not be shown again, and is needed when sending requests to Kommentar’s API. -
Restart the Kommentar container to apply the changes:
Terminal window docker stop kommentardocker rm kommentardocker run -d --env-file .env --name kommentar -p 3000:3000 kommentar
Setting up Kommentar for public access requires an additional step of configuring a reverse proxy, such as Nginx or Traefik, to handle incoming requests and route them to the Kommentar container.
This is not covered in this guide, but you can find many resources online on how to set up a reverse proxy. Some popular options include:
Upgrading
Section titled “Upgrading”Upgrading Kommentar is straightforward as long as you do not change the database schema or the code.
To upgrade Kommentar, you can follow these steps:
-
Pull the latest changes:
Terminal window git pull -
Rerun while forcing a rebuild:
If you are using Docker Compose:
Terminal window docker-compose up -d --build# ORdocker compose up -d --buildIf you are not using Docker Compose, you can rebuild the image and restart the container:
Terminal window docker build -t kommentar .docker stop kommentardocker rm kommentardocker run -d --env-file .env --name kommentar -p 3000:3000 kommentar -
Verify that Kommentar is running by accessing it at
http://localhost:3000
or the IP address of your server.