Skip to content

This is the main repository for the OpenChat application which runs on the Internet Computer

License

Notifications You must be signed in to change notification settings

open-chat-labs/open-chat

Repository files navigation

OpenChat

https://oc.app

OpenChat is a fully featured chat application running end-to-end on the Internet Computer blockchain.

Prerequisites

DFX 0.26.0-beta.1

To install, run DFX_VERSION=0.26.0-beta.1 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

Rust

To install, run curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

NPM

Download from https://nodejs.org/en/download

Testing locally

Start DFX using dfx start

To install all the necessary canisters (OpenChat and NNS) run ./scripts/deploy-local.sh

To run the website run npm --prefix frontend run dev. This process doesn't exit but watches changes to the website and rebuilds it using vite for fast development iteration.

Open the website at http://localhost:5001/.

To upgrade a canister run ./scripts/upgrade-canister-local.sh <DFX_IDENTITY_NAME> <CANISTER_NAME> <VERSION> (eg. ./scripts/upgrade-canister-local.sh default user 1.0.0)

To start again with a fresh install, stop DFX, then run rm -rf .dfx, then start from the top of these instructions again.

Deterministic builds

We need builds to be deterministic so that code running inside a canister can be verified by comparing the wasm hash locally with the wasm hash exposed by the IC.

You can build the OpenChat canister wasms by running ./scripts/docker-build-all-wasms.sh

Docker & bots

If you are developing bots on the Open Chat platform, you may want to download or build, and then run the open-chat docker image.

This image runs the Open Chat canisters and UI within the container, therefore removing the requirement for a local installation.

DockerHub registry

You may pull the latest open-chat image from the DockerHub:

docker pull --platform linux/amd64 openchatlabs/open-chat:latest

In case you get an unauthorised error when calling this command, please use docker logout / docker login to re-authorise.

Note: You may be able to use Docker Desktop app to download the image, but if your arch is different to amd64 you may get an error if you try to pull the image. We are unfortunatelly unable to provide arm64 image (yet), so we would recommend this step to be done in terminal.

Building the image

If you would prefer to build the image yourself, make sure to position yourself at the root of this repository.

If you are running x86/amd64 architecture, run the following command to build the image from the repository:

docker build -t open-chat -f Dockerfile.oc .

Or, in case your machine is based on arm64 architecture, build with buildx for amd64 platform (uses QUEMU under the bonnet):

docker buildx build -t open-chat -f Dockerfile.oc --platform linux/amd64 --load .

Note: it may take up to 10+ minutes to build the image.

Running the image

To run the open-chat image, once it's downloaded or built use either Docker Desktop, or from terminal:

docker run --platform linux/amd64 -d -p 5001:80 -p 8080:8080 --name open-chat openchatlabs/open-chat:latest

If you've built the image yourself, then the last argument should be equal to the value provided after the -t flag in the docker build command. In our build examples that value was open-chat.

Important: It may take up to a minute for the container to initialise dfx and start serving OC app correctly!

Once the container is fully running, the app UI should be available on http://localhost:5001.

Offchain vs Canister bots

With the offchain bots, there are no additional steps to take to get the bot connected to the OC app. It should be enough for the bot to run on another available localhost port, and for the OC app to be able to access it.

For the canister bots, make sure your dfx.json has the following networks entry:

{
  ...
  "networks": {
    "local": {
      "bind": "127.0.0.1:8080",
      "type": "ephemeral",
      "replica": {
        "subnet_type": "system"
      }
    }
  },
  ...
}

You will still need to have the dfx installed locally for issuing commands, but with the networks entry defined for networks.local.bind: 127.0.0.1:8080 those commands should apply to the dfx instance running within the Docker open-chat container.

Deploy a canister bot locally

If you're wondering about how to deploy your canister bot locally, there are a few exmaples of deployment scripts in the open-chat-bots repository that you may use (with minor modifications).

License

Copyright 2024 OpenChat Labs LTD

Licensed under the AGPLv3: https://www.gnu.org/licenses/agpl-3.0.html


Our tests run fast and cheap via RunsOn