honcho/docs/getting-started/self-hosting.mdx

64 lines
1.9 KiB
Plaintext

---
title: 'Self-Hosting Honcho'
sidebarTitle: 'Self-Hosting'
description: 'Running a local version of the Honcho API Server'
icon: 'cloud'
---
Honcho is a monorepo that contains the server and API to manage database interactions. It stores data about an application's state along with the python sdk for interacting with the API.
You can host it locally quite easily! This can be beneficial for iterative development, testing, and debugging. This guide will go through the different ways to host locally.
### Setup
1. Clone the repository:
```bash
git clone git@github.com:plastic-labs/honcho.git
```
2. Copy the `.env.template` file to `.env` and specify the type of database and `CONNECTION_URI`. For testing sqlite is fine. The below example uses a sqlite database with a local file:
> Honcho has been tested with Postgresql and SQLite
```env
DATABASE_TYPE=sqlite
CONNECTION_URI=sqlite:///api.db
```
Now the tutorial will diverge based on how you'd like to run the API.
### Poetry
This project utilizes [Poetry](https://python-poetry.org/) for dependency management, so you can run the API through a poetry virtual environment.
3. Create a virtualenv and install the API's dependencies:
```bash
cd honcho/api/ # change to the api directory
poetry shell # Activate virutal environment
poetry install # install dependencies
```
4. Run the API via uvicorn:
```bash
cd honcho/api # change to the api directory
poetry shell # Activate virtual environment if not already enabled
python -m uvicorn src.main:app --reload
```
### Docker
Alternatively there is also a `Dockerfile` included to run the API server from a docker container.
The `.env` file is not loaded into the docker container and should still be configured from outside.
3. Build the docker image:
```bash
cd honcho/api
docker build -t honcho-api .
```
4. Run the docker image:
```bash
docker run --env-file .env -p 8000:8000 honcho-api:latest
```