replace .env.development[production].local with .env.development[production];add env example
This commit is contained in:
@@ -30,9 +30,6 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ Before you begin, ensure your development environment has [Node.js](https://node
|
||||
cd backend
|
||||
npm install
|
||||
|
||||
# Create and configure .env.development.local according to the instructions in backend/README.md
|
||||
# Create and configure .env.development according to the instructions in backend/README.md
|
||||
|
||||
npm run dev # Starts by default at http://localhost:3001
|
||||
```
|
||||
@@ -62,7 +62,7 @@ Before you begin, ensure your development environment has [Node.js](https://node
|
||||
cd frontend
|
||||
pnpm install
|
||||
|
||||
# Create and configure .env.development.local according to the instructions in frontend/README.md
|
||||
# Create and configure .env.development according to the instructions in frontend/README.md
|
||||
|
||||
pnpm dev # Starts by default at http://localhost:3002
|
||||
```
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@ PrivyDrop (原 SecureShare) 是一个基于 WebRTC 的开源点对点(P2P)
|
||||
cd backend
|
||||
npm install
|
||||
|
||||
# 根据 backend/README.zh-CN.md 指引创建并配置 .env.development.local
|
||||
# 根据 backend/README.zh-CN.md 指引创建并配置 .env.development
|
||||
|
||||
npm run dev # 默认启动于 http://localhost:3001
|
||||
```
|
||||
@@ -62,7 +62,7 @@ PrivyDrop (原 SecureShare) 是一个基于 WebRTC 的开源点对点(P2P)
|
||||
cd frontend
|
||||
pnpm install
|
||||
|
||||
# 根据 frontend/README.zh-CN.md 指引创建并配置 .env.development.local
|
||||
# 根据 frontend/README.zh-CN.md 指引创建并配置 .env.development
|
||||
|
||||
pnpm dev # 默认启动于 http://localhost:3002
|
||||
```
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
BACKEND_PORT=3001
|
||||
|
||||
REDIS_HOST='localhost'
|
||||
REDIS_PORT=6379
|
||||
|
||||
CORS_ORIGIN=http://localhost:3002
|
||||
@@ -0,0 +1,18 @@
|
||||
BACKEND_PORT=3001
|
||||
|
||||
REDIS_HOST='localhost'
|
||||
REDIS_PORT=6379
|
||||
|
||||
CORS_ORIGIN=https://www.privydrop.app
|
||||
|
||||
# TURN Server Configuration
|
||||
TURN_EXTERNAL_IP=43.153.3.146
|
||||
TURN_REALM=turn.privydrop.app
|
||||
TURN_USERNAME=[Username]
|
||||
TURN_PASSWORD=[Password]
|
||||
TURN_CERT_PATH=/etc/letsencrypt/live/privydrop.app/fullchain.pem
|
||||
TURN_KEY_PATH=/etc/letsencrypt/live/privydrop.app/privkey.pem
|
||||
|
||||
# Nginx Configuration
|
||||
NGINX_SERVER_NAME=privydrop.app
|
||||
NGINX_FRONTEND_ROOT=[path/to/your/PrivyDrop/frontend]
|
||||
+1
-1
@@ -33,7 +33,7 @@ This is the backend server for PrivyDrop. It is built with Node.js, Express, and
|
||||
```
|
||||
|
||||
3. **Configure Environment Variables**
|
||||
Create a `.env.development.local` file in the `backend/` directory and populate it with the following variables:
|
||||
Create a `.env.development` file in the `backend/` directory and populate it with the following variables:
|
||||
|
||||
```ini
|
||||
# Server Configuration
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
```
|
||||
|
||||
3. **配置环境变量**
|
||||
在 `backend/` 目录中创建一个 `.env.development.local` 文件,并填充以下变量:
|
||||
在 `backend/` 目录中创建一个 `.env.development` 文件,并填充以下变量:
|
||||
|
||||
```ini
|
||||
# 服务器配置
|
||||
|
||||
@@ -39,6 +39,6 @@ for CERT_PATH in "$CERTBOT_DIR"/*/fullchain.pem; do
|
||||
echo "Failed to renew certificate for $DOMAIN"
|
||||
fi
|
||||
# Start nginx
|
||||
sudo bash configure.sh ../../.env.production.local
|
||||
sudo bash configure.sh ../../.env.production
|
||||
fi
|
||||
done
|
||||
@@ -16,8 +16,8 @@ interface AppConfig {
|
||||
dotenv.config({
|
||||
path:
|
||||
process.env.NODE_ENV === "production"
|
||||
? path.resolve(process.cwd(), ".env.production.local")
|
||||
: path.resolve(process.cwd(), ".env.development.local"),
|
||||
? path.resolve(process.cwd(), ".env.production")
|
||||
: path.resolve(process.cwd(), ".env.development"),
|
||||
});
|
||||
// Check for necessary Redis environment variables
|
||||
if (!process.env.REDIS_HOST) {
|
||||
|
||||
+7
-7
@@ -112,8 +112,8 @@ sudo apt install coturn
|
||||
|
||||
```bash
|
||||
# Located in the backend/ directory
|
||||
sudo bash ./docker/TURN/configure.sh path/to/your/.env.production.local
|
||||
# For a development environment, use .env.development.local
|
||||
sudo bash ./docker/TURN/configure.sh path/to/your/.env.production
|
||||
# For a development environment, use .env.development
|
||||
sudo systemctl status coturn
|
||||
```
|
||||
|
||||
@@ -179,7 +179,7 @@ In production, Nginx will act as the entry point for all traffic, handling SSL t
|
||||
4. **Nginx Configuration File:**
|
||||
The `backend/docker/Nginx/` directory in the project provides a configuration script and template.
|
||||
|
||||
- Add the `NGINX_*` related variables to your backend's `.env.production.local` file, including the domain, certificate paths, and the **root directory of the frontend build artifacts**. Example:
|
||||
- Add the `NGINX_*` related variables to your backend's `.env.production` file, including the domain, certificate paths, and the **root directory of the frontend build artifacts**. Example:
|
||||
|
||||
```
|
||||
NGINX_SERVER_NAME=yourdomain.com # The full domain name
|
||||
@@ -191,17 +191,17 @@ In production, Nginx will act as the entry point for all traffic, handling SSL t
|
||||
5. **Apply Configuration:** Generate the Nginx config, create a symbolic link, and restart Nginx.
|
||||
```bash
|
||||
# This script uses NGINX_* variables from your .env file to generate the Nginx config
|
||||
sudo bash backend/docker/Nginx/configure.sh backend/.env.production.local
|
||||
sudo bash backend/docker/Nginx/configure.sh backend/.env.production
|
||||
```
|
||||
|
||||
### 4.4. Configure Environment Variables
|
||||
|
||||
- **Backend:**
|
||||
- Create a `.env.production.local` file in the `backend/` directory.
|
||||
- Create a `.env.production` file in the `backend/` directory.
|
||||
- Fill in the necessary environment variables (e.g., `BACKEND_PORT`, `REDIS_HOST`, `REDIS_PORT`, `CORS_ORIGIN`).
|
||||
- For Nginx integration, also add `NGINX_SERVER_NAME`, `NGINX_SSL_CERT`, `NGINX_SSL_KEY`, and `NGINX_FRONTEND_ROOT`.
|
||||
- **Frontend:**
|
||||
- Create a `.env.production.local` file in the `frontend/` directory.
|
||||
- Create a `.env.production` file in the `frontend/` directory.
|
||||
- Fill in the `NEXT_PUBLIC_API_URL` variable.
|
||||
|
||||
### 4.5. Run the Application with PM2
|
||||
@@ -219,7 +219,7 @@ PM2 is a powerful process manager for Node.js. We will use it to run the backend
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
# Ensure .env.production.local is fully configured
|
||||
# Ensure .env.production is fully configured
|
||||
pm2 start ecosystem.config.js
|
||||
```
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ sudo apt install coturn
|
||||
|
||||
```bash
|
||||
# 位于 backend/ 目录
|
||||
sudo bash ./docker/TURN/configure.sh path/to/your/.env.production.local
|
||||
# 开发环境使用 .env.development.local
|
||||
sudo bash ./docker/TURN/configure.sh path/to/your/.env.production
|
||||
# 开发环境使用 .env.development
|
||||
sudo systemctl status coturn
|
||||
```
|
||||
|
||||
@@ -179,7 +179,7 @@ cd backend && npm build && cd ..
|
||||
4. **Nginx 配置文件:**
|
||||
后端项目 `backend/docker/Nginx/` 目录中提供了配置脚本和模板。
|
||||
|
||||
- 在后端的 `.env.production.local` 文件中添加 `NGINX_*` 相关变量,包括域名、证书路径和**前端构建产物的根目录**,示例为:
|
||||
- 在后端的 `.env.production` 文件中添加 `NGINX_*` 相关变量,包括域名、证书路径和**前端构建产物的根目录**,示例为:
|
||||
|
||||
```
|
||||
NGINX_SERVER_NAME=yourdomain # 不带 www 前缀,yourdomain包含了后缀
|
||||
@@ -190,16 +190,16 @@ cd backend && npm build && cd ..
|
||||
|
||||
5. **应用配置:** 创建软链接并重启 Nginx。
|
||||
```bash
|
||||
# 此脚本会使用 .env.production.local 中的 NGINX_* 变量来生成 Nginx 配置文件
|
||||
sudo bash docker/Nginx/configure.sh .env.production.local
|
||||
# 此脚本会使用 .env.production 中的 NGINX_* 变量来生成 Nginx 配置文件
|
||||
sudo bash docker/Nginx/configure.sh .env.production
|
||||
```
|
||||
|
||||
### 4.4. 配置环境变量
|
||||
|
||||
- **后端:**
|
||||
- 在 `backend/` 目录下创建 `.env.production.local` 或 `.env.development.local` 文件
|
||||
- 在 `.env.development.local` 文件中填入环境变量 (BACKEND_PORT, REDIS_HOST, REDIS_PORT, CORS_ORIGIN)。
|
||||
- 在 `.env.production.local` 文件中除了上述变量外,还要加入 (NGINX_SERVER_NAME, NGINX_SSL_CERT, NGINX_SSL_KEY, NGINX_FRONTEND_ROOT)。
|
||||
- 在 `backend/` 目录下创建 `.env.production` 或 `.env.development` 文件
|
||||
- 在 `.env.development` 文件中填入环境变量 (BACKEND_PORT, REDIS_HOST, REDIS_PORT, CORS_ORIGIN)。
|
||||
- 在 `.env.production` 文件中除了上述变量外,还要加入 (NGINX_SERVER_NAME, NGINX_SSL_CERT, NGINX_SSL_KEY, NGINX_FRONTEND_ROOT)。
|
||||
- **前端:** 在 `frontend/` 目录下创建 `.env.production` 或 `.env.development` 文件,并填入环境变量 (NEXT_PUBLIC_API_URL)。
|
||||
|
||||
### 4.5. 使用 PM2 运行应用
|
||||
@@ -217,7 +217,7 @@ PM2 是一个强大的 Node.js 进程管理器,我们将用它来分别运行
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
# 确保 .env.production.local 已配置完毕
|
||||
# 确保 .env.production 已配置完毕
|
||||
pm2 start ecosystem.config.js
|
||||
```
|
||||
|
||||
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
NEXT_PUBLIC_API_URL=http://43.142.81.156:3001
|
||||
@@ -0,0 +1,5 @@
|
||||
NEXT_PUBLIC_API_URL=https://www.privydrop.app
|
||||
|
||||
NEXT_PUBLIC_TURN_HOST=turn.privydrop.app
|
||||
NEXT_PUBLIC_TURN_USERNAME=[Username]
|
||||
NEXT_PUBLIC_TURN_PASSWORD=[Password]
|
||||
+1
-1
@@ -25,7 +25,7 @@ Before you start, please ensure you have **installed and started the backend ser
|
||||
pnpm install
|
||||
```
|
||||
3. **Configure Environment Variables**
|
||||
Create a `.env.development.local` file in the `frontend/` directory and add the necessary environment variables for development. At a minimum, you need to specify the backend API address:
|
||||
Create a `.env.development` file in the `frontend/` directory and add the necessary environment variables for development. At a minimum, you need to specify the backend API address:
|
||||
```ini
|
||||
NEXT_PUBLIC_API_URL=http://localhost:3001
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
pnpm install
|
||||
```
|
||||
3. **配置环境变量**
|
||||
在 `frontend/` 目录下创建 `.env.development.local` 文件,并填入开发所需的环境变量,至少需要指定后端 API 的地址:
|
||||
在 `frontend/` 目录下创建 `.env.development` 文件,并填入开发所需的环境变量,至少需要指定后端 API 的地址:
|
||||
```ini
|
||||
NEXT_PUBLIC_API_URL=http://localhost:3001
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user