diff --git a/aws/cloudformation/DEPLOY.md b/cloud-deployments/aws/cloudformation/DEPLOY.md similarity index 89% rename from aws/cloudformation/DEPLOY.md rename to cloud-deployments/aws/cloudformation/DEPLOY.md index 9d739d88..3b3e2777 100644 --- a/aws/cloudformation/DEPLOY.md +++ b/cloud-deployments/aws/cloudformation/DEPLOY.md @@ -12,7 +12,7 @@ With an AWS account you can easily deploy a private AnythingLLM instance on AWS. Done. **Custom Launch** -[Refer to .env.example](../../docker/HOW_TO_USE_DOCKER.md) for data format. +[Refer to .env.example](../../../docker/HOW_TO_USE_DOCKER.md) for data format. The output of this cloudformation stack will be: - 1 EC2 Instance @@ -32,11 +32,11 @@ The output of this cloudformation stack will be: 4. Ensure you are deploying in a geographic zone that is nearest to your physical location to reduce latency. 5. Click `Create Stack` -![Create Stack](/images/screenshots/create_stack.png) +![Create Stack](../../../images/screenshots/create_stack.png) 6. Upload your `aws_cf_deploy_anything_llm.json` to the stack -![Upload Stack](/images/screenshots/upload.png) +![Upload Stack](../../../images/screenshots/upload.png) 7. Click `Next` and give your stack a name. This is superficial. 8. No other changes are needed, just proceed though each step @@ -44,7 +44,7 @@ The output of this cloudformation stack will be: 10. Wait for stack events to finish and be marked as `Completed` 11. View `Outputs` tab. -![Stack Output](/images/screenshots/cf_outputs.png) +![Stack Output](../../../images/screenshots/cf_outputs.png) ## Please read this notice before submitting issues about your deployment diff --git a/aws/cloudformation/aws_no_creds.json b/cloud-deployments/aws/cloudformation/aws_no_creds.json similarity index 100% rename from aws/cloudformation/aws_no_creds.json rename to cloud-deployments/aws/cloudformation/aws_no_creds.json diff --git a/aws/cloudformation/cf_template.template b/cloud-deployments/aws/cloudformation/cf_template.template similarity index 100% rename from aws/cloudformation/cf_template.template rename to cloud-deployments/aws/cloudformation/cf_template.template diff --git a/aws/cloudformation/generate.mjs b/cloud-deployments/aws/cloudformation/generate.mjs similarity index 97% rename from aws/cloudformation/generate.mjs rename to cloud-deployments/aws/cloudformation/generate.mjs index dce7981c..99ed03ca 100644 --- a/aws/cloudformation/generate.mjs +++ b/cloud-deployments/aws/cloudformation/generate.mjs @@ -15,7 +15,7 @@ import { exit } from 'process'; const __dirname = dirname(fileURLToPath(import.meta.url)); const REPLACEMENT_KEY = '!SUB::USER::CONTENT!' -const envPath = path.resolve(__dirname, `../../docker/.env`) +const envPath = path.resolve(__dirname, `../../../docker/.env`) const envFileExists = fs.existsSync(envPath); const chalk = { diff --git a/digitalocean/terraform/DEPLOY.md b/cloud-deployments/digitalocean/terraform/DEPLOY.md similarity index 96% rename from digitalocean/terraform/DEPLOY.md rename to cloud-deployments/digitalocean/terraform/DEPLOY.md index efcca3a4..1e78cf82 100644 --- a/digitalocean/terraform/DEPLOY.md +++ b/cloud-deployments/digitalocean/terraform/DEPLOY.md @@ -2,7 +2,7 @@ With a DigitalOcean account, you can easily deploy a private AnythingLLM instance using Terraform. This will create a URL that you can access from any browser over HTTP (HTTPS not supported). This single instance will run on your own keys, and they will not be exposed. However, if you want your instance to be protected, it is highly recommended that you set the `AUTH_TOKEN` and `JWT_SECRET` variables in the `docker/` ENV. -[Refer to .env.example](../../docker/HOW_TO_USE_DOCKER.md) for data format. +[Refer to .env.example](../../../docker/HOW_TO_USE_DOCKER.md) for data format. The output of this Terraform configuration will be: - 1 DigitalOcean Droplet diff --git a/digitalocean/terraform/main.tf b/cloud-deployments/digitalocean/terraform/main.tf similarity index 95% rename from digitalocean/terraform/main.tf rename to cloud-deployments/digitalocean/terraform/main.tf index ae6bd8a5..b5669027 100644 --- a/digitalocean/terraform/main.tf +++ b/cloud-deployments/digitalocean/terraform/main.tf @@ -27,7 +27,7 @@ resource "digitalocean_droplet" "anything_llm_instance" { } locals { - env_content = file("../../docker/.env") + env_content = file("../../../docker/.env") formatted_env_content = join("\n", [ for line in split("\n", local.env_content) : line diff --git a/digitalocean/terraform/outputs.tf b/cloud-deployments/digitalocean/terraform/outputs.tf similarity index 100% rename from digitalocean/terraform/outputs.tf rename to cloud-deployments/digitalocean/terraform/outputs.tf diff --git a/digitalocean/terraform/user_data.tp1 b/cloud-deployments/digitalocean/terraform/user_data.tp1 similarity index 100% rename from digitalocean/terraform/user_data.tp1 rename to cloud-deployments/digitalocean/terraform/user_data.tp1 diff --git a/gcp/deployment/DEPLOY.md b/cloud-deployments/gcp/deployment/DEPLOY.md similarity index 97% rename from gcp/deployment/DEPLOY.md rename to cloud-deployments/gcp/deployment/DEPLOY.md index 3628c435..dea5acc7 100644 --- a/gcp/deployment/DEPLOY.md +++ b/cloud-deployments/gcp/deployment/DEPLOY.md @@ -2,7 +2,7 @@ With a GCP account you can easily deploy a private AnythingLLM instance on GCP. This will create a url that you can access from any browser over HTTP (HTTPS not supported). This single instance will run on your own keys and they will not be exposed - however if you want your instance to be protected it is highly recommend that you set the `AUTH_TOKEN` and `JWT_SECRET` variables in the `docker/` ENV. -[Refer to .env.example](../../docker/HOW_TO_USE_DOCKER.md) for data format. +[Refer to .env.example](../../../docker/HOW_TO_USE_DOCKER.md) for data format. The output of this cloudformation stack will be: - 1 GCP VM diff --git a/gcp/deployment/gcp_deploy_anything_llm.yaml b/cloud-deployments/gcp/deployment/gcp_deploy_anything_llm.yaml similarity index 100% rename from gcp/deployment/gcp_deploy_anything_llm.yaml rename to cloud-deployments/gcp/deployment/gcp_deploy_anything_llm.yaml diff --git a/cloud-deployments/gcp/deployment/generate.mjs b/cloud-deployments/gcp/deployment/generate.mjs new file mode 100644 index 00000000..a8868251 --- /dev/null +++ b/cloud-deployments/gcp/deployment/generate.mjs @@ -0,0 +1,61 @@ +import fs from 'fs'; +import { fileURLToPath } from 'url'; +import path, { dirname } from 'path'; +import { exit } from 'process'; +const __dirname = dirname(fileURLToPath(import.meta.url)); +const REPLACEMENT_KEY = '!SUB::USER::CONTENT!' + +const envPath = path.resolve(__dirname, `../../../docker/.env`) +const envFileExists = fs.existsSync(envPath); + +const chalk = { + redBright: function (text) { + return `\x1b[31m${text}\x1b[0m` + }, + cyan: function (text) { + return `\x1b[36m${text}\x1b[0m` + }, + greenBright: function (text) { + return `\x1b[32m${text}\x1b[0m` + }, + blueBright: function (text) { + return `\x1b[34m${text}\x1b[0m` + } +} + +if (!envFileExists) { + console.log(chalk.redBright('[ABORT]'), 'You do not have an .env file in your ./docker/ folder. You need to create it first.'); + console.log('You can start by running', chalk.cyan('cp -n ./docker/.env.example ./docker/.env')) + exit(1); +} + +// Remove comments +// Remove UID,GID,etc +// Remove empty strings +// Split into array +const settings = fs.readFileSync(envPath, "utf8") + .replace(/^#.*\n?/gm, '') + .replace(/^UID.*\n?/gm, '') + .replace(/^GID.*\n?/gm, '') + .replace(/^CLOUD_BUILD.*\n?/gm, '') + .replace(/^\s*\n/gm, "") + .split('\n') + .filter((i) => !!i); +const formattedSettings = settings.map((i, index) => index === 0 ? i + '\n' : ' ' + i).join('\n'); + +// Read the existing GCP Deployment Manager template +const templatePath = path.resolve(__dirname, `gcp_deploy_anything_llm.yaml`); +const templateString = fs.readFileSync(templatePath, "utf8"); + +// Update the metadata section with the UserData content +const updatedTemplateString = templateString.replace(REPLACEMENT_KEY, formattedSettings); + +// Save the updated GCP Deployment Manager template +const output = path.resolve(__dirname, `gcp_deploy_anything_llm_with_env.yaml`); +fs.writeFileSync(output, updatedTemplateString, "utf8"); + +console.log(chalk.greenBright('[SUCCESS]'), 'Deploy AnythingLLM on GCP Deployment Manager using your template document.'); +console.log(chalk.greenBright('File Created:'), 'gcp_deploy_anything_llm_with_env.yaml in the output directory.'); +console.log(chalk.blueBright('[INFO]'), 'Refer to the GCP Deployment Manager documentation for how to use this file.'); + +exit(); diff --git a/gcp/deployment/generate.mjs b/gcp/deployment/generate.mjs deleted file mode 100644 index 2ac93bb4..00000000 --- a/gcp/deployment/generate.mjs +++ /dev/null @@ -1,61 +0,0 @@ -import fs from 'fs'; -import { fileURLToPath } from 'url'; -import path, { dirname } from 'path'; -import { exit } from 'process'; -const __dirname = dirname(fileURLToPath(import.meta.url)); -const REPLACEMENT_KEY = '!SUB::USER::CONTENT!' - -const envPath = path.resolve(__dirname, `../../docker/.env`) -const envFileExists = fs.existsSync(envPath); - -const chalk = { - redBright: function (text) { - return `\x1b[31m${text}\x1b[0m` - }, - cyan: function (text) { - return `\x1b[36m${text}\x1b[0m` - }, - greenBright: function (text) { - return `\x1b[32m${text}\x1b[0m` - }, - blueBright: function (text) { - return `\x1b[34m${text}\x1b[0m` - } -} - -if (!envFileExists) { - console.log(chalk.redBright('[ABORT]'), 'You do not have an .env file in your ./docker/ folder. You need to create it first.'); - console.log('You can start by running', chalk.cyan('cp -n ./docker/.env.example ./docker/.env')) - exit(1); -} - -// Remove comments -// Remove UID,GID,etc -// Remove empty strings -// Split into array -const settings = fs.readFileSync(envPath, "utf8") - .replace(/^#.*\n?/gm, '') - .replace(/^UID.*\n?/gm, '') - .replace(/^GID.*\n?/gm, '') - .replace(/^CLOUD_BUILD.*\n?/gm, '') - .replace(/^\s*\n/gm, "") - .split('\n') - .filter((i) => !!i); -const formattedSettings = settings.map((i, index) => index === 0 ? i + '\n' : ' ' + i).join('\n'); - -// Read the existing GCP Deployment Manager template -const templatePath = path.resolve(__dirname, `gcp_deploy_anything_llm.yaml`); -const templateString = fs.readFileSync(templatePath, "utf8"); - -// Update the metadata section with the UserData content -const updatedTemplateString = templateString.replace(REPLACEMENT_KEY, formattedSettings); - -// Save the updated GCP Deployment Manager template -const output = path.resolve(__dirname, `gcp_deploy_anything_llm_with_env.yaml`); -fs.writeFileSync(output, updatedTemplateString, "utf8"); - -console.log(chalk.greenBright('[SUCCESS]'), 'Deploy AnythingLLM on GCP Deployment Manager using your template document.'); -console.log(chalk.greenBright('File Created:'), 'gcp_deploy_anything_llm_with_env.yaml in the output directory.'); -console.log(chalk.blueBright('[INFO]'), 'Refer to the GCP Deployment Manager documentation for how to use this file.'); - -exit(); diff --git a/package.json b/package.json index dba56203..7df9953f 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "dev:frontend": "cd frontend && yarn start", "prod:server": "cd server && yarn start", "prod:frontend": "cd frontend && yarn build", - "generate:cloudformation": "node aws/cloudformation/generate.mjs", - "generate::gcp_deployment": "node gcp/deployment/generate.mjs" + "generate:cloudformation": "node cloud-deployments/aws/cloudformation/generate.mjs", + "generate::gcp_deployment": "node cloud-deployments/gcp/deployment/generate.mjs" }, "private": false } \ No newline at end of file