diff --git a/.gitignore b/.gitignore index d8fa784..558b175 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ api/**/*.db - +api/data +api/docker-compose.yml # Byte-compiled / optimized / DLL files diff --git a/README.md b/README.md index 0845a28..b0539c3 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,19 @@ directories. ### API +#### Docker + +The API can be run using docker-compose. The `docker-compose.yml.example` file can be copied to `docker-compose.yml` and the environment variables can be set in the `.env` file. + +```bash +cd honcho/api +cp docker-compose.yml.example docker-compose.yml +[ update the file with openai key and other wanted environment variables ] +docker compose up -d +``` + +#### Manually + The API can be run either by installing the necessary dependencies and then specifying the appropriate environment variables. @@ -48,7 +61,7 @@ poetry install # install dependencies 2. Copy the `.env.template` file and specify the type of database and connection_uri. For testing sqlite is fine. The below example uses an - in-memory sqlite database. + in-memory sqlite database. > Honcho has been tested with Postgresql and PGVector @@ -72,26 +85,11 @@ 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. - -```bash -cd honcho/api -docker build -t honcho-api . -docker run --env-file .env -p 8000:8000 honcho-api:latest -``` - #### Deploy on Fly The API can also be deployed on fly.io. Follow the [Fly.io Docs](https://fly.io/docs/getting-started/) to setup your environment and the -`flyctl`. - +`flyctl`. Once `flyctl` is set up use the following commands to launch the application: @@ -134,12 +132,12 @@ See more information [here](https://python-poetry.org/docs/cli/#add) This project is completely open source and welcomes any and all open source contributions. The workflow for contributing is to make a fork of the repository. You can claim an issue in the issues tab or start a new thread to -indicate a feature or bug fix you are working on. +indicate a feature or bug fix you are working on. Once you have finished your contribution make a PR pointed at the `staging` branch, and it will be reviewed by a project manager. Feel free to join us in our [discord](http://discord.gg/plasticlabs) to discuss your changes or get -help. +help. Once your changes are accepted and merged into staging they will undergo a period of live testing before entering the upstream into `main` diff --git a/api/docker-compose.yml.example b/api/docker-compose.yml.example new file mode 100644 index 0000000..60fc24d --- /dev/null +++ b/api/docker-compose.yml.example @@ -0,0 +1,39 @@ +version: "3.8" +services: + api: + build: + context: . + dockerfile: Dockerfile + ports: + - 8000:8000 + volumes: + - .:/app + environment: + - DATABASE_TYPE=postgres + - CONNECTION_URI=postgresql://testuser:testpwd@database:5432/honcho + - OPENAI_API_KEY=[YOUR_OPENAI_API_KEY] + - OPENTELEMETRY_ENABLED=false + - SENTRY_ENABLED=false + - SENTRY_DSN= + - OTEL_SERVICE_NAME=honcho + - OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true + - OTEL_PYTHON_LOG_CORRELATION=true + - OTEL_PYTHON_LOG_LEVEL= + - OTEL_EXPORTER_OTLP_PROTOCOL= + - OTEL_EXPORTER_OTLP_ENDPOINT= + - OTEL_EXPORTER_OTLP_HEADERS= + - OTEL_RESOURCE_ATTRIBUTES= + - DEBUG_LOG_OTEL_TO_PROVIDER=false + - DEBUG_LOG_OTEL_TO_CONSOLE=true + database: + image: ankane/pgvector + restart: always + environment: + - POSTGRES_DB=honcho + - POSTGRES_USER=testuser + - POSTGRES_PASSWORD=testpwd + - POSTGRES_HOST_AUTH_METHOD=trust + - PGDATA=/var/lib/postgresql/data/pgdata + volumes: + - ./local/init.sql:/docker-entrypoint-initdb.d/init.sql + - ./data:/var/lib/postgresql/data/