Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
rickcert committed Nov 14, 2024
2 parents 6abcbf7 + 552d364 commit 6bebc34
Show file tree
Hide file tree
Showing 19 changed files with 2,863 additions and 641 deletions.
89 changes: 29 additions & 60 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,106 +1,75 @@
# 阶段1:基础镜像准备
FROM node:18-alpine AS base

ARG USE_CN_MIRROR

# 设置工作目录
WORKDIR /app

# 配置国内镜像源(如果需要)
RUN \
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
npm config set registry https://registry.npmmirror.com/; \
fi
# 配置国内镜像源
RUN npm config set registry https://registry.npmmirror.com/

# 安装必要的系统依赖(例如CA证书
# 安装必要的系统依赖(例如 CA 证书
RUN apk add --no-cache ca-certificates

# 创建distroless目录,准备复制必要的运行时文件
RUN mkdir -p /distroless/bin /distroless/lib /distroless/etc/ssl/certs /distroless/etc

# 复制Node.js可执行文件
RUN cp /usr/local/bin/node /distroless/bin/

# 复制Node.js运行时依赖的库文件
RUN ldd /usr/local/bin/node | awk '{print $3}' | grep -v '^$' | xargs -I '{}' cp '{}' /distroless/lib/

# 复制动态链接器
RUN cp /lib/ld-musl-$(uname -m).so.1 /distroless/lib/

# 复制CA证书
RUN cp -r /etc/ssl/certs /distroless/etc/ssl/

# 创建非root用户
RUN addgroup -g 1001 appgroup && \
adduser -D -u 1001 -G appgroup appuser

# 复制用户和组信息
RUN cp /etc/passwd /distroless/etc/passwd && \
cp /etc/group /distroless/etc/group



# 阶段2:构建应用程序
FROM base AS builder

ARG USE_CN_MIRROR

WORKDIR /app

# 复制依赖文件
COPY package.json yarn.lock ./

# 确保在构建阶段NODE_ENV不为production
ENV NODE_ENV=development

# 配置国内镜像源并安装依赖
RUN \
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
npm config set registry https://registry.npmmirror.com/; \
fi && \
yarn install
# 安装所有依赖,包括开发依赖
RUN yarn install

# 复制项目源代码
COPY . .

# 构建应用程序
RUN yarn build

# 重新设置NODE_ENV为production
# 删除 node_modules 目录
RUN rm -rf node_modules

# 设置 NODE_ENV 为 production
ENV NODE_ENV=production

# 删除devDependencies,减小最终镜像大小
# 安装生产依赖
RUN yarn install --production --ignore-scripts --prefer-offline

# 修改文件权限,使appuser拥有所有权
RUN chown -R appuser:appgroup /app


# 清理 yarn 缓存
RUN yarn cache clean --all

# 阶段3:构建最终的生产镜像
FROM scratch
FROM node:18-alpine

# 设置工作目录
WORKDIR /app

# 复制distroless文件
COPY --from=base /distroless /
# 创建非 root 用户
RUN addgroup -g 1001 appgroup && \
adduser -D -u 1001 -G appgroup appuser

# 复制应用程序文件
COPY --from=builder /app /app
COPY --from=builder /app/server.js /app/server.js
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/api /app/api
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/package.json /app/package.json

# 修改文件权限,使 appuser 拥有所有权
RUN chown -R appuser:appgroup /app

# 设置环境变量
ENV NODE_ENV=production
ENV HOSTNAME="0.0.0.0"
ENV PORT=13000
ENV NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca"

# 设置工作目录
WORKDIR /app

# 暴露端口
EXPOSE 13000

# 使用非root用户
# 使用非 root 用户
USER appuser

# 启动命令
ENTRYPOINT ["/bin/node"]
CMD ["server.js"]
CMD ["node", "server.js"]
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@

<img src="./docs/images/testing.png" alt="测试" style="zoom:50%;" />

### v2.1.0

🔔 **新特性与优化**

-**新增快捷聊天测试**
- 对接魔改 NextChat,可快捷测试模型。
- 新增 `closeChat` 设置,方便中转站使用。
- 🧪 **添加实验性功能模块** from [elfmaid](https://linux.do/u/elfmaid)
- 批量测试 gpt Refresh Tokens
- 批量测试 claude Session Keys
- 批量测试 gemini API Keys
- ✂️ **新增粘贴按钮 ** by [fangyuan](https://linux.do/u/fangyuan99)
- 📝 **新增自定义对话验证功能**
- 快捷prompt测试 by [fangyuan](https://linux.do/u/fangyuan99)

🔧 **优化与修复**

- 🐳 **优化 Dockerfile** 减小镜像体积。

- 🎨 **修复布局问题** 改善界面显示

### v2.0.0

🔔 **全新特性与优化**
Expand Down Expand Up @@ -171,8 +192,13 @@
- **描述**: 是否关闭公告显示。设置为 `true` 时关闭公告显示,设置为 `false` 或未定义时显示公告。 **方便中转站使用**
- **示例**: `"closeAnnouncement": true`

🚪 closeChat **方便中转站使用**

- **描述**:是否关闭快捷聊天功能。设置为 `true` 时关闭聊天功能,设置为 `false` 或未定义时开启聊天功能。
- **示例**`"closeChat": true`

```
https://check.crond.dev/?settings={"key":"*sk*","url":"*api*","models":["gpt-4o-mini","gpt-4o"],"timeout":10,"concurrency":2,"closeAnnouncement":true}
https://check.crond.dev/?settings={"key":"*sk*","url":"*api*","models":["gpt-4o-mini","gpt-4o"],"timeout":10,"concurrency":2,"closeAnnouncement":true,"closeChat":true}
```

解码后的 JSON 字符串如下:
Expand All @@ -184,26 +210,29 @@ https://check.crond.dev/?settings={"key":"*sk*","url":"*api*","models":["gpt-4o-
"models": ["gpt-4o-mini", "gpt-4o"],
"timeout": 10,
"concurrency": 2,
"closeAnnouncement": true
"closeAnnouncement": true,
"closeChat": true
}
```

- **voapi** 示例

```
{
"name": "check",
"link": "https://check.crond.dev/?settings={%22key%22:%22*sk*%22,%22url%22:%22*api*%22,%22models%22:[%22gpt-4o-mini%22],%22timeout%22:10,%22concurrency%22:2,%22closeAnnouncement%22:true}",
"icon": "https://check.crond.dev/logo.png"
"name": "check",
"link": "https://check.crond.dev/?settings={%22key%22:%22*sk*%22,%22url%22:%22*api*%22,%22models%22:[%22gpt-4o-mini%22],%22timeout%22:10,%22concurrency%22:2,%22closeAnnouncement%22:true,%22closeChat%22:true}",
"icon": "https://check.crond.dev/logo.png"
}
```

- **newapi** 示例

```
{
"CHECK": "https://check.crond.dev/?settings={\"key\":\"{key}\",\"url\":\"{address}\",\"models\":[\"gpt-4o-mini\"],\"timeout\":10,\"concurrency\":2,\"closeAnnouncement\":true}"
"CHECK": "https://check.crond.dev/?settings={\"key\":\"{key}\",\"url\":\"{address}\",\"models\":[\"gpt-4o-mini\"],\"timeout\":10,\"concurrency\":2,\"closeAnnouncement\":true,\"closeChat\":true}"
}
```

### 🛠 **高级验证功能**
Expand Down
Loading

0 comments on commit 6bebc34

Please sign in to comment.