From 29b5ce1563966e8ff97ec0fd968f35e3874e4d7e Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Wed, 21 Jun 2023 22:11:28 -0500 Subject: [PATCH] Adds additional documentation on starting out (#197) --- .env.example | 1 + apps/platform/src/config/database.ts | 4 +- apps/ui/tsconfig.json | 13 ++---- docs/docs/deploy/aws-ec2.md | 14 +++++-- docs/docs/deploy/deploy.md | 2 +- docs/docs/deploy/digitalocean.md | 59 +++++++++++++++++++++++++++- 6 files changed, 75 insertions(+), 18 deletions(-) diff --git a/.env.example b/.env.example index 17a5d677..bccaa175 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ APP_SECRET=Ck7Rt1uiy5WGbrTFj1HBjymbBoA6zqih BASE_URL=/ UI_PORT=3000 +NODE_ENV=production DB_CLIENT=mysql2 DB_HOST=mysql diff --git a/apps/platform/src/config/database.ts b/apps/platform/src/config/database.ts index 3ba6e82f..5563ab7b 100644 --- a/apps/platform/src/config/database.ts +++ b/apps/platform/src/config/database.ts @@ -75,15 +75,13 @@ export default async (config: DatabaseConfig) => { await migrate(config, db) return db } catch (error: any) { - - logger.error(error, 'database error') - if (error?.errno === 1049) { // On error, try to create the database and try again const db = connect(config, false) await migrate(config, db, true) return connect(config) } else { + logger.error(error, 'database error') throw error } } diff --git a/apps/ui/tsconfig.json b/apps/ui/tsconfig.json index 56c9d309..cb75051d 100644 --- a/apps/ui/tsconfig.json +++ b/apps/ui/tsconfig.json @@ -1,27 +1,20 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - // "target": "es2021", "lib": [ "dom", "dom.iterable", "esnext" ], - // "allowJs": true, - // "skipLibCheck": true, - // "esModuleInterop": true, - // "allowSyntheticDefaultImports": true, - // "strict": true, - // "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", - // "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "react-jsx", + "declarationDir": "types", }, "include": [ "src" ] -} +} \ No newline at end of file diff --git a/docs/docs/deploy/aws-ec2.md b/docs/docs/deploy/aws-ec2.md index f69292a3..def96297 100644 --- a/docs/docs/deploy/aws-ec2.md +++ b/docs/docs/deploy/aws-ec2.md @@ -14,14 +14,17 @@ This page guides you through deploying Parcelvoy Open-Source on an Amazon EC2 in 2. Install Docker ```sh sudo yum update -y -sudo yum install -y docker +sudo yum install -y docker containerd git screen sudo service docker start sudo usermod -a -G docker $USER ``` 3. Install `docker-compose` ```sh -sudo yum install -y docker-compose-plugin +wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) +sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/libexec/docker/cli-plugins/docker-compose +chmod +x /usr/libexec/docker/cli-plugins/docker-compose +sudo systemctl enable docker.service --now docker compose version ``` @@ -48,5 +51,10 @@ This file also lets you use a separate database, change what queue is being used By default the port is configured to use `3000` for the UI and API. You can modify this by setting `UI_PORT`. -6. Setup security groups +6. Bring containers online +``` +docker compose up -d # run the Docker container +``` + +7. Setup security groups Based on what port you are using for the UI portion, you will want to make sure you have configured that port to be open as well in your security groups. diff --git a/docs/docs/deploy/deploy.md b/docs/docs/deploy/deploy.md index 4ceb0c52..ef5e26cf 100644 --- a/docs/docs/deploy/deploy.md +++ b/docs/docs/deploy/deploy.md @@ -7,7 +7,7 @@ While Docker Compose is the fastest way to get up and running, we recommend at l The fastest way to get up and running is by using Docker Compose. Every component including the database is included in the compose file and you'll be up and running quickly. ## Scalable Deploy -Every part of Parcelvoy is developed to be able to scale to multiple servers as your use increases. We've broken down the major components you'll want to +Every part of Parcelvoy is developed to be able to scale to multiple servers as your use increases. We've broken down the major components you'll want to separate to provide a truly scalable solution: 1. Database 2. Queue diff --git a/docs/docs/deploy/digitalocean.md b/docs/docs/deploy/digitalocean.md index adad9c75..3ab2e4a6 100644 --- a/docs/docs/deploy/digitalocean.md +++ b/docs/docs/deploy/digitalocean.md @@ -1,3 +1,60 @@ --- title: Digital Ocean ---- \ No newline at end of file +--- + +This page guides you through deploying Parcelvoy Open-Source on a Digital Ocean droplet by setting up the deployment environment, installing and starting Parcelvoy, and connecting it to the droplet. + +## Requirements +- A $14/mo droplet or larger. While you can run it on a smaller droplet, performance may not be optimal. + +## Setup +1. [Create a DigitalOcean droplet](https://docs.digitalocean.com/products/droplets/how-to/create/) running Ubuntu +2. Connect to the droplet either through SSH or using the Droplet Console +3. Update the available packages and install Docker +```sh +sudo apt update +sudo apt install apt-transport-https ca-certificates curl software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" +sudo apt install docker-ce +sudo systemctl status docker +sudo usermod -aG docker ${USER} +su - ${USER} +``` + +4. Install `docker-compose` +```sh +sudo apt install docker-compose-plugin +docker compose version +``` + +5. Download Parcelvoy configuration: +``` +mkdir parcelvoy && cd parcelvoy +wget https://raw.githubusercontent.com/parcelvoy/platform/master/{.env.example,docker-compose.yml} +``` + +6. Setup environment variables +``` +mv .env.example .env +``` + +For default installations, security is set to `basic` which only allows for a single user. Before proceeding please update the email, password and app secret to not be their default values. + +``` +APP_SECRET=//Please pick a random value at least 16 characters in length +AUTH_BASIC_EMAIL=test@parcelvoy.com +AUTH_BASIC_PASSWORD=password +``` + +This file also lets you use a separate database, change what queue is being used or setup SSO. + +By default the port is configured to use `3000` for the UI and API. You can modify this by setting `UI_PORT`. + +7. Bring containers online +``` +docker compose up -d # run the Docker container +``` + +8. Setup firewall +Based on what port you are using for the UI portion, you will want to make sure you have configured that port to be open as well in your firewall.