Skip to content

Commit 9368ad3

Browse files
authored
Merge pull request #2 from liguobao/main
feat: add docker build
2 parents 4c11139 + cf98803 commit 9368ad3

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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"]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ yarn run build
7070
node 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
## 贡献

docker-compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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 # 用你的启动命令替换如果有必要

0 commit comments

Comments
 (0)