|
@@ -0,0 +1,84 @@
|
|
|
+# Workers部署文档
|
|
|
+
|
|
|
+[toc]
|
|
|
+
|
|
|
+## **环境要求**
|
|
|
+
|
|
|
+- image-processing
|
|
|
+
|
|
|
+ - node >=16.20.0
|
|
|
+
|
|
|
+ - wrangler >=3.5.0
|
|
|
+
|
|
|
+- text-to-image
|
|
|
+
|
|
|
+ - rust
|
|
|
+
|
|
|
+ - wrangler
|
|
|
+
|
|
|
+
|
|
|
+## **环境安装**
|
|
|
+
|
|
|
+### node 安装
|
|
|
+
|
|
|
+ 可从此处下载nvm[[GitHub - coreybutler/nvm-windows: A node.js version management utility for Windows. Ironically written in Go.](https://github.com/coreybutler/nvm-windows)]
|
|
|
+
|
|
|
+```bash
|
|
|
+nvm use 21
|
|
|
+```
|
|
|
+
|
|
|
+### wrangler 安装
|
|
|
+
|
|
|
+```bash
|
|
|
+npm install wrangler -g
|
|
|
+```
|
|
|
+
|
|
|
+### Rust安装
|
|
|
+
|
|
|
+参见此教程[入门 - Rust 程序设计语言 (rust-lang.org)](https://www.rust-lang.org/zh-CN/learn/get-started)
|
|
|
+
|
|
|
+## **安装基本依赖**
|
|
|
+
|
|
|
+- ImageProcessing
|
|
|
+
|
|
|
+ ```bash
|
|
|
+ npm install
|
|
|
+ ```
|
|
|
+- text-to-image
|
|
|
+
|
|
|
+ 此项目在部署时会自动安装所需依赖
|
|
|
+
|
|
|
+## **[可选]更改配置文件**
|
|
|
+
|
|
|
+ 修改`wrangler.toml`文件内的`[vars]`节,以修改环境变量。以下列出了常用的配置项。
|
|
|
+
|
|
|
+| 属性 | 默认值 | 作用 |
|
|
|
+| ---- | ------ | ---- |
|
|
|
+|aws_base_url|'plat-sg-cloudflare-testing.s3.ap-southeast-1.amazonaws.com'|未使用预签名URL时,图片回源的AWS地址|
|
|
|
+|self_host|'cf-test.hoyoverse.com'|自身部署的Host|
|
|
|
+|text_to_image_url|'https://text-to-image.hoyoverse.workers.dev/'|提供文字转图片的Workers URL,仅用于添加水印|
|
|
|
+
|
|
|
+## **部署**
|
|
|
+
|
|
|
+1. 执行以下命令进行部署
|
|
|
+ ```bash
|
|
|
+ npm run deploy
|
|
|
+ ```
|
|
|
+
|
|
|
+2. 在弹出的网页中进行登陆(可能需要关闭VPN)
|
|
|
+
|
|
|
+3. 在CLI中选择要部署的账户
|
|
|
+
|
|
|
+4. 等待上传完成
|
|
|
+
|
|
|
+ ![image-20231122194557100](https://gitee.com/shiqiguo/figurebed/raw/master/img/image-20231122194557100.png)
|
|
|
+
|
|
|
+5. 更新密钥
|
|
|
+
|
|
|
+ 1. ```bash
|
|
|
+ wrangler secret put accessKeyId
|
|
|
+ ```
|
|
|
+
|
|
|
+ 2. ```bash
|
|
|
+ wrangler secret put secretAccessKey
|
|
|
+ ```
|