feat: Added local development guide (#39)
* Added local development guide * Added local development guide * Added local development guide * Update local.mdx --------- Co-authored-by: harshsbhat <icybhat@gmail.com> Co-authored-by: KM Koushik <koushikmohan1996@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f10d446267
commit
bc237c881c
20
.env.example
Normal file
20
.env.example
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
DATABASE_URL="postgresql://unsend:password@localhost:54320/unsend"
|
||||||
|
REDIS_URL="redis://localhost:6379"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NEXTAUTH_URL="http://localhost:3000"
|
||||||
|
|
||||||
|
GITHUB_ID=""
|
||||||
|
GITHUB_SECRET=""
|
||||||
|
|
||||||
|
AWS_DEFAULT_REGION="us-east-1"
|
||||||
|
AWS_SECRET_KEY=""
|
||||||
|
AWS_ACCESS_KEY=""
|
||||||
|
|
||||||
|
NEXTAUTH_SECRET=""
|
||||||
|
|
||||||
|
|
||||||
|
API_RATE_LIMIT=2
|
||||||
|
|
||||||
|
NEXT_PUBLIC_IS_CLOUD=false
|
@@ -70,13 +70,9 @@ We're currently working on opening unsend for public beta.
|
|||||||
|
|
||||||
## Local Development
|
## Local Development
|
||||||
|
|
||||||
### Requirements
|
Follow our detailed guide to run Unsend locally
|
||||||
|
|
||||||
To run Unsend locally, you will need
|
[http://localhost:3002/get-started/local](http://localhost:3002/get-started/local)
|
||||||
|
|
||||||
- Node.js (v18 or above)
|
|
||||||
- Postgres SQL Database
|
|
||||||
- Docker (optional)
|
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
|
200
apps/docs/get-started/local.mdx
Normal file
200
apps/docs/get-started/local.mdx
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
---
|
||||||
|
title: Local Development
|
||||||
|
description: "A guide on how to run Unsend’s codebase locally"
|
||||||
|
icon: code
|
||||||
|
---
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Unsend's codebase is fully [open-source on github](https://github.com/unsend-dev/unsend)
|
||||||
|
|
||||||
|
Here is the codebase structure
|
||||||
|
|
||||||
|
```
|
||||||
|
apps
|
||||||
|
├── docs
|
||||||
|
├── marketing
|
||||||
|
├── web
|
||||||
|
packages
|
||||||
|
├── eslint-config
|
||||||
|
├── sdk
|
||||||
|
├── tailwind-config
|
||||||
|
├── typescript-config
|
||||||
|
├── ui
|
||||||
|
```
|
||||||
|
|
||||||
|
The ```apps``` directory contains the code for:
|
||||||
|
|
||||||
|
- ```web```: Code for our dashboard and email infra
|
||||||
|
|
||||||
|
- ```marketing```: The code for the landing page of Unsend
|
||||||
|
|
||||||
|
- ```docs```: The documentation that you are currently reading.
|
||||||
|
|
||||||
|
The ```packages``` directory contains the code for:
|
||||||
|
|
||||||
|
- ```eslint-config``` package contains shared ESLint configuration settings
|
||||||
|
|
||||||
|
- ```sdk``` package contains typescript sdk for unsend rest api
|
||||||
|
|
||||||
|
- ```tailwind-config``` This package contains a shared Tailwind CSS configuration.
|
||||||
|
|
||||||
|
- ```typescript-config``` This package contains a shared typescript configuration
|
||||||
|
|
||||||
|
- ```ui``` This package is a collection of reusable UI components like buttons, badges, etc
|
||||||
|
|
||||||
|
## Running Unsend locally
|
||||||
|
|
||||||
|
To run Unsend, locally you will need to setup the following:
|
||||||
|
|
||||||
|
- [AWS](https://aws.amazon.com/) Free tier account will work.
|
||||||
|
|
||||||
|
- [Cloudflare](https://www.cloudflare.com/) Free tier account will work.
|
||||||
|
|
||||||
|
- [Docker](https://docs.docker.com/engine/install/) Recommended but not mandatory
|
||||||
|
|
||||||
|
## Fork and Clone the repo
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Fork the repo">
|
||||||
|
Click on the fork button on [Github](https://github.com/unsend-dev/unsend) to fork the repo
|
||||||
|
</Step>
|
||||||
|
<Step title="Clone the repo">
|
||||||
|
Once the repo is forked you can clone it on your local machine using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/your-username/unsend.git
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
## Install Dependencies
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step>
|
||||||
|
```bash
|
||||||
|
corepack enable
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
|
||||||
|
<Step>
|
||||||
|
```bash
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
## Setup environment variables:
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Copy the env.example file into .env">
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Nextauth secret">
|
||||||
|
Use the following command to generate a key and add it under ```NEXTAUTH_SECRET```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
openssl rand -base64 32
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Setup Github Oauth">
|
||||||
|
|
||||||
|
Next, [create a new GitHub App](https://github.com/settings/applications/new). This will allow you to sign in to Unsend with your GitHub account.4
|
||||||
|
|
||||||
|
Add the homepage as:
|
||||||
|
|
||||||
|
```
|
||||||
|
http://localhost:3000/login
|
||||||
|
```
|
||||||
|
|
||||||
|
and callback URL as:
|
||||||
|
```
|
||||||
|
http://localhost:3000/api/auth/callback/github
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the app is added you can add the Client ID under ``GITHUB_ID``and CLIENT SECRET under ```GITHUB_SECRET```
|
||||||
|
</Step>
|
||||||
|
<Step title="Setup AWS credentials">
|
||||||
|
|
||||||
|
Next, we need to add in the [AWS credentials](https://docs.unsend.dev/get-started/create-aws-credentials). Follow the detailed guide to get the AWS credentials with accurate permissions and add them in:
|
||||||
|
|
||||||
|
```
|
||||||
|
AWS_ACCESS_KEY_ID=<access-key-id>
|
||||||
|
AWS_SECRET_ACCESS_KEY=<secret-access-key>
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the app is added you can add the Client ID under ``GITHUB_ID``and CLIENT SECRET under ```GITHUB_SECRET```
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
## Running Unsend locally
|
||||||
|
We are using a local Postgresql server and a local Redis server. But if you don't have docker you can also manually set these up.
|
||||||
|
|
||||||
|
### Option 1: Using Docker Recommended
|
||||||
|
<Steps>
|
||||||
|
<Step title="Start the dashboard">
|
||||||
|
```bash
|
||||||
|
pnpm d
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Dashboard and Landing page will start running">
|
||||||
|
Dashboard will be started on
|
||||||
|
```bash
|
||||||
|
http://localhost:3000
|
||||||
|
```
|
||||||
|
Landing page will be started on
|
||||||
|
|
||||||
|
```bash
|
||||||
|
http://localhost:3001
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Once you login with Github you will be prompted with SES settings. You will need to run cloudflare tunnel to add the callback URL">
|
||||||
|
Run the following command to get the URL. Here is the more detailed guide by [cloudflare](https://developers.cloudflare.com/pages/how-to/preview-with-cloudflare-tunnel/)
|
||||||
|
```bash
|
||||||
|
cloudflared tunnel --url http://localhost:3000
|
||||||
|
```
|
||||||
|
|
||||||
|
You can paste the URL provided by cloudflare in the Callback URL section
|
||||||
|
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
### Option 2: Using your own database or hosted database
|
||||||
|
<Steps>
|
||||||
|
<Step title="Set up your PostgreSQL and Redis database in Environment Variables">
|
||||||
|
```bash
|
||||||
|
DATABASE_URL=""
|
||||||
|
REDIS_URL=""
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Migrate the database">
|
||||||
|
```bash
|
||||||
|
pnpm db:migrate-dev
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Start the development server">
|
||||||
|
```bash
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
</Step>
|
||||||
|
<Step title="Once you login with Github you will be prompted with SES settings. You will need to run cloudflare tunnel to add the callback URL">
|
||||||
|
Run the following command to get the URL. Here is the more detailed guide by [cloudflare](https://developers.cloudflare.com/pages/how-to/preview-with-cloudflare-tunnel/)
|
||||||
|
```bash
|
||||||
|
cloudflared tunnel --url http://localhost:3000
|
||||||
|
```
|
||||||
|
|
||||||
|
You can paste the URL provided by cloudflare in the Callback URL section
|
||||||
|
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
|
||||||
|
## Run documentation
|
||||||
|
|
||||||
|
To run the documentation run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm dev:docs
|
||||||
|
```
|
@@ -49,6 +49,7 @@
|
|||||||
"pages": [
|
"pages": [
|
||||||
"introduction",
|
"introduction",
|
||||||
"get-started/nodejs",
|
"get-started/nodejs",
|
||||||
|
"get-started/local",
|
||||||
"get-started/self-hosting"
|
"get-started/self-hosting"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user