From d094cc3c109f58540bea36b5f561b5c11f6d109c Mon Sep 17 00:00:00 2001
From: Timothy Carambat <rambat1010@gmail.com>
Date: Wed, 13 Dec 2023 19:55:23 -0800
Subject: [PATCH] docs: update deployment templates to just pull the docker
 image (#445)

docs: update deployment templates to just pull the docker image and boot that instead of building
---
 .../cloudformation/aws_https_instructions.md  |  4 +-
 .../cloudformation_create_anythingllm.json    | 24 +++------
 .../digitalocean/terraform/main.tf            |  2 +-
 .../digitalocean/terraform/user_data.tp1      | 47 ++----------------
 cloud-deployments/gcp/deployment/DEPLOY.md    |  2 +-
 .../deployment/gcp_deploy_anything_llm.yaml   | 49 ++-----------------
 6 files changed, 19 insertions(+), 109 deletions(-)

diff --git a/cloud-deployments/aws/cloudformation/aws_https_instructions.md b/cloud-deployments/aws/cloudformation/aws_https_instructions.md
index 16c804888..5eb3cc753 100644
--- a/cloud-deployments/aws/cloudformation/aws_https_instructions.md
+++ b/cloud-deployments/aws/cloudformation/aws_https_instructions.md
@@ -80,10 +80,10 @@ These instructions are for CLI configuration and assume you are logged in to EC2
 1. $sudo certbot --nginx -d [Insert FQDN here] 
     Example command: $sudo certbot --nginx -d anythingllm.exampleorganization.org
     This command will generate the appropriate certificate files, write the files to /etc/letsencrypt/live/yourFQDN, and make updates to the nginx
-    configuration file for anythingllm locdated at /etc/nginx/conf.d/anything.llm
+    configuration file for anythingllm located at /etc/nginx/conf.d/anything.llm
 3. Enter the email address you would like to use for updates.
 4. Accept the terms of service.
-5. Accept or decline to recieve communication from letsencrypt.
+5. Accept or decline to receive communication from LetsEncrypt.
 
 ## Step 10: Test Cert installation
 1. $sudo cat /etc/nginx/conf.d/anything.conf
diff --git a/cloud-deployments/aws/cloudformation/cloudformation_create_anythingllm.json b/cloud-deployments/aws/cloudformation/cloudformation_create_anythingllm.json
index 1fca10dc9..1c944f4bb 100644
--- a/cloud-deployments/aws/cloudformation/cloudformation_create_anythingllm.json
+++ b/cloud-deployments/aws/cloudformation/cloudformation_create_anythingllm.json
@@ -5,7 +5,7 @@
     "InstanceType": {
       "Description": "EC2 instance type",
       "Type": "String",
-      "Default": "t2.small"
+      "Default": "t3.small"
     },
     "InstanceVolume": {
       "Description": "Storage size of disk on Instance in GB",
@@ -83,28 +83,16 @@
                 "#!/bin/bash\n",
                 "# check output of userdata script with sudo tail -f /var/log/cloud-init-output.log\n",
                 "sudo yum install docker -y\n",
-                "sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose\n",
-                "sudo chmod +x /usr/local/bin/docker-compose\n",
-                "sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose\n",
                 "sudo systemctl enable docker\n",
                 "sudo systemctl start docker\n",
-                "sudo yum install git -y\n",
-                "git clone https://github.com/Mintplex-Labs/anything-llm.git /home/ec2-user/anything-llm\n",
-                "touch /home/ec2-user/anything-llm/server/storage/anythingllm.db\n",
-                "cd /home/ec2-user/anything-llm/docker\n",
-                "cp .env.example .env\n",
-                "cd ../frontend\n",
-                "rm -rf .env.production\n",
-                "cat >> .env.production << \"END\"\n",
-                "GENERATE_SOURCEMAP=true\n",
-                "VITE_API_BASE=\"/api\"\n",
-                "END\n",
-                "sudo chown ec2-user:ec2-user -R /home/ec2-user/anything-llm\n",
-                "sudo docker-compose -f /home/ec2-user/anything-llm/docker/docker-compose.yml up -d\n",
+                "mkdir -p /home/ec2-user/anythingllm\n",
+                "touch /home/ec2-user/anythingllm/.env\n",
+                "sudo chown ec2-user:ec2-user -R /home/ec2-user/anythingllm\n",
+                "docker pull mintplexlabs/anythingllm:master\n",
+                "docker run -d -p 3001:3001 -v /home/ec2-user/anythingllm:/app/server/storage -v /home/ec2-user/anythingllm/.env:/app/server/.env -e STORAGE_DIR=\"/app/server/storage\" mintplexlabs/anythingllm:master\n",
                 "echo \"Container ID: $(sudo docker ps --latest --quiet)\"\n",
                 "export ONLINE=$(curl -Is http://localhost:3001/api/ping | head -n 1|cut -d$' ' -f2)\n",
                 "echo \"Health check: $ONLINE\"\n",
-                "if [ \"$ONLINE\" = 200 ] ; then echo \"Running migrations...\" && curl -Is http://localhost:3001/api/migrate | head -n 1|cut -d$' ' -f2; fi\n",
                 "echo \"Setup complete! AnythingLLM instance is now online!\"\n",
                 "\n",
                 "--//--\n"
diff --git a/cloud-deployments/digitalocean/terraform/main.tf b/cloud-deployments/digitalocean/terraform/main.tf
index b56690271..331d254e3 100644
--- a/cloud-deployments/digitalocean/terraform/main.tf
+++ b/cloud-deployments/digitalocean/terraform/main.tf
@@ -19,7 +19,7 @@ resource "digitalocean_droplet" "anything_llm_instance" {
   image  = "ubuntu-22-10-x64"  
   name   = "anything-llm-instance"  
   region = "nyc3"  
-  size   = "s-1vcpu-1gb"  
+  size   = "s-2vcpu-2gb"  
   
   user_data = templatefile("user_data.tp1", {   
     env_content = local.formatted_env_content 
diff --git a/cloud-deployments/digitalocean/terraform/user_data.tp1 b/cloud-deployments/digitalocean/terraform/user_data.tp1
index 7e7451b38..a8705be4b 100644
--- a/cloud-deployments/digitalocean/terraform/user_data.tp1
+++ b/cloud-deployments/digitalocean/terraform/user_data.tp1
@@ -5,55 +5,16 @@ sudo apt-get update
 sudo apt-get install -y docker.io  
 sudo usermod -a -G docker ubuntu
   
-curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose  
-sudo chmod +x /usr/local/bin/docker-compose  
-sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose  
-  
 sudo systemctl enable docker  
 sudo systemctl start docker  
   
-sudo apt-get install -y git  
+mkdir -p /home/anythingllm
+touch /home/anythingllm/.env
   
-git clone https://github.com/Mintplex-Labs/anything-llm.git /home/anything-llm  
-cd /home/anything-llm/docker  
-  
-cat >> .env << END
-${env_content}
-UID="1000"  
-GID="1000"  
-NO_DEBUG="true"  
-END
-  
-echo "Set .env file"  
-  
-cd ../frontend
-sudo rm -rf .env.production  
-  
-sudo cat >> .env.production << END
-GENERATE_SOURCEMAP=true  
-VITE_API_BASE="/api"  
-END
-  
-echo "Set .env.production file"  
-  
-cd ../docker  
-sudo docker-compose up -d --build  
+sudo docker pull mintplexlabs/anythingllm:master
+sudo docker run -d -p 3001:3001 -v /home/anythingllm:/app/server/storage -v /home/anythingllm/.env:/app/server/.env -e STORAGE_DIR="/app/server/storage" mintplexlabs/anythingllm:master
 echo "Container ID: $(sudo docker ps --latest --quiet)"  
   
-sudo docker container exec -u 0 -t $(sudo docker ps --latest --quiet) mkdir -p /app/server/storage /app/server/storage/documents /app/server/storage/vector-cache /app/server/storage/lancedb  
-echo "Placeholder folders in storage created."  
-  
-sudo docker container exec -u 0 -t $(sudo docker ps --latest --quiet) touch /app/server/storage/anythingllm.db  
-echo "SQLite DB placeholder set."  
-  
-sudo docker container exec -u 0 -t $(sudo docker ps --latest --quiet) chown -R anythingllm:anythingllm /app/collector /app/server  
-echo "File permissions corrected."  
-  
 export ONLINE=$(curl -Is http://localhost:3001/api/ping | head -n 1|cut -d$' ' -f2)  
 echo "Health check: $ONLINE"  
-  
-if [ "$ONLINE" = 200 ]; then  
-  echo "Running migrations..." && curl -Is http://localhost:3001/api/migrate | head -n 1 | cut -d$' ' -f2  
-fi  
-  
 echo "Setup complete! AnythingLLM instance is now online!"  
diff --git a/cloud-deployments/gcp/deployment/DEPLOY.md b/cloud-deployments/gcp/deployment/DEPLOY.md
index dea5acc7f..10249096d 100644
--- a/cloud-deployments/gcp/deployment/DEPLOY.md
+++ b/cloud-deployments/gcp/deployment/DEPLOY.md
@@ -51,7 +51,7 @@ gcloud deployment-manager deployments delete anything-llm-deployment
 ## Please read this notice before submitting issues about your deployment
 
 **Note:** 
-Your instance will not be available instantly. Depending on the instance size you launched with it can take anywhere from 10-20 minutes to fully boot up.
+Your instance will not be available instantly. Depending on the instance size you launched with it can take anywhere from 5-10 minutes to fully boot up.
 
 If you want to check the instances progress, navigate to [your deployed instances](https://console.cloud.google.com/compute/instances) and connect to your instance via SSH in browser.
 
diff --git a/cloud-deployments/gcp/deployment/gcp_deploy_anything_llm.yaml b/cloud-deployments/gcp/deployment/gcp_deploy_anything_llm.yaml
index 61dd059db..74658327e 100644
--- a/cloud-deployments/gcp/deployment/gcp_deploy_anything_llm.yaml
+++ b/cloud-deployments/gcp/deployment/gcp_deploy_anything_llm.yaml
@@ -27,57 +27,18 @@ resources:
               sudo apt-get update  
               sudo apt-get install -y docker.io  
               sudo usermod -a -G docker ubuntu
-
-              curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose  
-              sudo chmod +x /usr/local/bin/docker-compose  
-              sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose  
-
               sudo systemctl enable docker  
               sudo systemctl start docker  
 
-              sudo apt-get install -y git  
-
-              git clone https://github.com/Mintplex-Labs/anything-llm.git /home/anything-llm  
-              cd /home/anything-llm/docker  
-
-              cat >> .env << END
-              !SUB::USER::CONTENT!
-              UID="1000"  
-              GID="1000"  
-              NO_DEBUG="true"  
-              END
-
-              echo "Set .env file" 
-
-              cd ../frontend  
-              sudo rm -rf .env.production  
-
-              sudo cat >> .env.production << END
-              GENERATE_SOURCEMAP=true  
-              VITE_API_BASE="/api"  
-              END
-
-              echo "Set .env.production file" 
-
-              cd ../docker
-              sudo docker-compose up -d --build  
+              mkdir -p /home/anythingllm
+              touch /home/anythingllm/.env
+               
+              sudo docker pull mintplexlabs/anythingllm:master
+              sudo docker run -d -p 3001:3001 -v /home/anythingllm:/app/server/storage -v /home/anythingllm/.env:/app/server/.env -e STORAGE_DIR="/app/server/storage" mintplexlabs/anythingllm:master
               echo "Container ID: $(sudo docker ps --latest --quiet)"  
 
-              sudo docker container exec -u 0 -t $(sudo docker ps --latest --quiet) mkdir -p /app/server/storage /app/server/storage/documents /app/server/storage/vector-cache /app/server/storage/lancedb  
-              echo "Placeholder folders in storage created."  
-
-              sudo docker container exec -u 0 -t $(sudo docker ps --latest --quiet) touch /app/server/storage/anythingllm.db  
-              echo "SQLite DB placeholder set."  
-
-              sudo docker container exec -u 0 -t $(sudo docker ps --latest --quiet) chown -R anythingllm:anythingllm /app/collector /app/server  
-              echo "File permissions corrected."  
-
               export ONLINE=$(curl -Is http://localhost:3001/api/ping | head -n 1|cut -d$' ' -f2)  
               echo "Health check: $ONLINE"  
 
-              if [ "$ONLINE" = 200 ]; then
-                echo "Running migrations..." && curl -Is http://localhost:3001/api/migrate | head -n 1 | cut -d$' ' -f2
-              fi
-
               echo "Setup complete! AnythingLLM instance is now online!"