File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # 构建阶段
2+ FROM node:lts-alpine AS builder
3+
4+ WORKDIR /app
5+
6+ COPY package.json yarn.lock* /app/
7+
8+ RUN yarn install --frozen-lockfile
9+
10+ COPY . /app
11+
12+ RUN yarn run build
13+
14+ # 运行阶段
15+ FROM node:lts-alpine
16+
17+ WORKDIR /app
18+
19+ # 从构建阶段复制输出文件到运行容器
20+ COPY --from=builder /app/.output /app
21+
22+ # 暴露容器运行时的端口
23+ EXPOSE 3000
24+
25+ CMD ["node" , "server/index.mjs" ]
Original file line number Diff line number Diff line change @@ -70,6 +70,13 @@ yarn run build
7070node server/index.mjs
7171```
7272
73+ ## Docker 运行
74+
75+ ``` bash
76+ docker build -t webcamera .
77+ docker run -d -p 3000:3000 webcamera
78+ ```
79+
7380** 自部署请注意** : 浏览器媒体权限(摄像头和麦克风等)需要地址为` localhost ` 或使用` HTTPS ` 才能正常申请和启用,请自行配置` HTTPS ` 部署。
7481
7582## 贡献
Original file line number Diff line number Diff line change 1+ version : ' 3.8'
2+ services :
3+ app :
4+ build :
5+ context : .
6+ dockerfile : Dockerfile
7+ ports :
8+ - " 3000:3000"
9+ environment :
10+ - NODE_ENV=production # 设置环境变量,如果需要的话
11+ command : node server/index.mjs # 用你的启动命令替换如果有必要
You can’t perform that action at this time.
0 commit comments