2023-09-07 11:36:39 +00:00
# Self-hosting DocsGPT on Amazon Lightsail
2023-10-26 05:47:19 +00:00
Here's a step-by-step guide on how to set up an Amazon Lightsail instance to host DocsGPT.
2023-09-07 11:36:39 +00:00
## Configuring your instance
2023-10-17 17:46:13 +00:00
(If you know how to create a Lightsail instance, you can skip to the recommended configuration part by clicking [here ](#connecting-to-your-newly-created-instance )).
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
### 1. Create an AWS Account:
2023-10-12 13:22:54 +00:00
If you haven't already, create or log in to your AWS account at https://lightsail.aws.amazon.com.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
### 2. Create an Instance:
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
a. Click "Create Instance."
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
b. Select the "Instance location." In most cases, the default location works fine.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
c. Choose "Linux/Unix" as the image and "Ubuntu 20.04 LTS" as the Operating System.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
d. Configure the instance plan based on your requirements. A "1 GB, 1vCPU, 40GB SSD, and 2TB transfer" setup is recommended for most scenarios.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
e. Give your instance a unique name and click "Create Instance."
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
PS: It may take a few minutes for the instance setup to complete.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
### Connecting to Your newly created Instance
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
Your instance will be ready a few minutes after creation. To access it, open the instance and click "Connect using SSH."
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
#### Clone the DocsGPT Repository
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
A terminal window will pop up, and the first step will be to clone the DocsGPT Git repository:
2023-09-07 11:36:39 +00:00
`git clone https://github.com/arc53/DocsGPT.git`
#### Download the package information
2023-10-12 13:22:54 +00:00
Once it has finished cloning the repository, it is time to download the package information from all sources. To do so, simply enter the following command:
2023-09-07 11:36:39 +00:00
`sudo apt update`
2023-10-12 13:22:54 +00:00
#### Install Docker and Docker Compose
2023-09-07 11:36:39 +00:00
2023-10-04 12:26:25 +00:00
DocsGPT backend and worker use Python, Frontend is written on React and the whole application is containerized using Docker. To install Docker and Docker Compose, enter the following commands:
2023-09-07 11:36:39 +00:00
2023-09-15 10:00:59 +00:00
`sudo apt install docker.io`
And now install docker-compose:
`sudo apt install docker-compose`
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
#### Access the DocsGPT Folder
2023-09-07 11:36:39 +00:00
2023-10-16 09:30:11 +00:00
Enter the following command to access the folder in which the DocsGPT docker-compose file is present.
2023-09-15 10:00:59 +00:00
`cd DocsGPT/`
2023-10-12 03:19:40 +00:00
#### Prepare the Environment
2023-09-15 10:00:59 +00:00
2023-10-12 03:19:40 +00:00
Inside the DocsGPT folder create a `.env` file and copy the contents of `.env_sample` into it.
2023-09-07 11:36:39 +00:00
2023-09-15 10:00:59 +00:00
`nano .env`
2023-09-07 11:36:39 +00:00
2023-10-05 17:27:48 +00:00
Make sure your `.env` file looks like this:
2023-09-07 11:36:39 +00:00
2023-09-15 10:00:59 +00:00
```
OPENAI_API_KEY=(Your OpenAI API key)
VITE_API_STREAMING=true
SELF_HOSTED_MODEL=false
```
2023-09-07 11:36:39 +00:00
2023-10-04 12:26:25 +00:00
To save the file, press CTRL+X, then Y, and then ENTER.
2023-09-15 10:00:59 +00:00
2023-10-12 03:19:40 +00:00
Next, set the correct IP for the Backend by opening the docker-compose.yml file:
2023-09-15 10:00:59 +00:00
`nano docker-compose.yml`
2023-10-12 03:19:40 +00:00
And Change line 7 to: `VITE_API_HOST=http://localhost:7091`
2023-09-15 10:00:59 +00:00
to this `VITE_API_HOST=http://<your instance public IP>:7091`
This will allow the frontend to connect to the backend.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
#### Running the Application
2023-09-07 11:36:39 +00:00
You're almost there! Now that all the necessary bits and pieces have been installed, it is time to run the application. To do so, use the following command:
2023-09-15 10:00:59 +00:00
`sudo docker-compose up -d`
2023-09-07 11:36:39 +00:00
2023-10-04 12:26:25 +00:00
Launching it for the first time will take a few minutes to download all the necessary dependencies and build.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
Once this is done you can go ahead and close the terminal window.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
#### Enabling Ports
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
a. Before you are able to access your live instance, you must first enable the port that it is using.
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
b. Open your Lightsail instance and head to "Networking".
2023-09-07 11:36:39 +00:00
2023-10-12 03:19:40 +00:00
c. Then click on "Add rule" under "IPv4 Firewall", enter `5173` as your port, and hit "Create".
2023-10-05 17:27:48 +00:00
Repeat the process for port `7091` .
2023-09-07 11:36:39 +00:00
#### Access your instance
2023-10-12 03:19:40 +00:00
Your instance is now available at your Public IP Address on port 5173. Enjoy using DocsGPT!
2023-10-17 22:39:50 +00:00
## Other Deployment Options
- [Deploy DocsGPT on Civo Compute Cloud ](https://dev.to/rutamhere/deploying-docsgpt-on-civo-compute-c )
2023-11-06 13:59:51 +00:00
- [Deploy DocsGPT on DigitalOcean Droplet ](https://dev.to/rutamhere/deploying-docsgpt-on-digitalocean-droplet-50ea )
2023-12-26 10:58:57 +00:00
- [Deploy DocsGPT on Kamatera Performance Cloud ](https://dev.to/rutamhere/deploying-docsgpt-on-kamatera-performance-cloud-1bj )