Skip to content

Dockerized Deployment of LibreChat

The LibreChat project is built around Docker making deployment a breeze in a variety of environments. In the last section, we created a DigitalOcean Droplet running Ubuntu 22.04. In this section, we will install Docker on the Droplet and deploy the LibreChat project using Docker.

The LibreChat Docker deployment guide walks through the process indicating explicitly that the installation is the “best” and may not be the quickest. The reason for this claim is that it’s meant to make long-term maintenance easier in terms of updates and security patches etc.

  1. SSH into your DigitalOcean Droplet using the following command:

    Terminal window
    ssh <yourusername>@<your-droplet-ip>
  2. Update the package list and install the required dependencies:

    Terminal window
    sudo apt update
    Terminal window
    sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release

    This will install a number of packages:

    • apt-transport-https - allows the use of repositories accessed via the HTTP Secure protocol (HTTPS)
      • ca-certificates - allows the system to check the authenticity of SSL certificates
      • curl - a command-line tool for transferring data with URLs
      • software-properties-common - provides an abstraction of the used apt repositories and allows for easy management of software sources
      • gnupg - GNU Privacy Guard, a complete and free implementation of the OpenPGP standard as defined by RFC4880 (also known as PGP)
      • lsb-release - provides information about the Linux distribution you are using to help with package management
  1. Add the Docker GPG key to your system:

    Terminal window
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  2. Add the repository to the source list

    Terminal window
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  3. Refresh your packges

    Terminal window
    sudo apt update
  1. Install Docker

    Terminal window
    sudo apt install docker-ce docker-ce-cli containerd.io

    The LibreChat guide suggests installing the docker-ce package, which is the community edition of Docker. This is the recommended package for our purpose. They note that many Linux distributions have docker-io packages in their repositories, but the Docker repository is the best place to get the latest version.

  2. Ensure your user has permissions to run Docker commands:

    Terminal window
    sudo usermod -aG docker $USER
  3. Reboot the server

    Terminal window
    sudo reboot
  4. Your SSH session will be disconnected. Wait a few moments and then SSH back into the server.

    Terminal window
    ssh <yourusername>@<your-droplet-ip>
  5. Change users to your non-root user:

    Terminal window
    su - <yourusername>
  6. Verify that Docker is installed and running:

    Terminal window
    sudo systemctl status docker

    You should see output indicating that Docker is active and running:

    Docker Active and Running

The LibreChat docker guide inidcates that the version of Docker Compose available in the Ubuntu repositories may not be the latest version. They recommend installing the latest version from the Docker GitHub repository.

  1. Download the latest version of Docker Compose:

    Terminal window
    sudo curl -L https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

    Docker Compose Install

  2. Apply executable permissions to the binary:

    Terminal window
    sudo chmod +x /usr/local/bin/docker-compose
  3. Verify that Docker Compose is installed:

    Terminal window
    docker-compose --version

    You should see output indicating the version of Docker Compose that you installed:

If you’ve browsed through the LibreChat documenations, you may have noticed that it is a very active project. This means that there are frequent updates and changes. To ensure that you have the latest version of the project, you will need to install Git and NPM which will make updating the app easier.

  1. Install git, nodejs and npm:

    Terminal window
    sudo apt install git nodejs npm

    This will install the latest versions of Git, Node.js, and NPM on your server so be patient as it may take a few moments. Note that the packages are pretty darn old. You can check the versions by running:

    Terminal window
    git --version
    node --version
    npm --version

Step 6: Update Git, Node.js, and NPM (Optional)

Section titled “Step 6: Update Git, Node.js, and NPM (Optional)”

Git

  1. Add the Git PPA:

    Terminal window
    sudo add-apt-repository ppa:git-core/ppa

    This will output a description that tells us we are on track and where we want to be: “The most current stable version of Git for Ubuntu”

  2. Make sure to update the package list:

Terminal window
sudo apt update
  1. Install the latest stable version of Git:
Terminal window
sudo apt install git
Terminal window
git --version

Node.js and NPM

  1. Add the NodeSource repository:
Terminal window
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
  1. Install Node.js and NPM:

    Terminal window
    sudo apt install -y nodejs

    If your installation was successful you should see the following output. If not, ensure you’ve removed the older conflicting package and fixed the broken dependencies.

    Node.js and NPM Install

  2. Verify the installation:

    Terminal window
    node --version
    npm --version

    You should see output indicating the versions of Node.js and NPM that you installed. Yours should be at least as recent as the versions shown below:

    Node.js and NPM Versions

The Ubuntu Droplet is now prepped and ready to install the app. Here is a recap of the steps we’ve taken:

  • Created a DigitalOcean Droplet running Ubuntu 22.04
  • Updated the package list and installed required dependencies
  • Added the Docker repository to the source list
  • Installed Docker and Docker Compose
  • Installed Git, Node.js, and NPM
  • Updated Git, Node.js, and NPM (optional)

Jump over to the next section to deploy the LibreChat app using Docker.