refactor: simplify Dockerfile for development and add docker-compose

- Simplify Dockerfile to single-stage development setup
- Add docker-compose.yml for easier container management

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
User
2026-01-09 01:56:46 +00:00
parent 026e33a08a
commit 2baa8fb143
2 changed files with 17 additions and 23 deletions

View File

@@ -1,33 +1,20 @@
# ==================== 构建阶段 ====================
FROM node:24-alpine AS builder
FROM node:24-alpine
WORKDIR /app
# 配置 npm 镜像
# 配置阿里云 npm 镜像
RUN npm config set registry https://registry.npmmirror.com
# 复制依赖文件并安装
# 复制依赖文件
COPY package*.json ./
RUN npm ci
# 复制源代码并构建
# 安装所有依赖(包括 devDependencies
RUN npm install
# 复制源代码
COPY . .
RUN npm run build
# ==================== 运行阶段 ====================
FROM node:24-alpine AS runner
WORKDIR /app
# 只安装服务器依赖(独立的 package.json
COPY server/package.json ./
RUN npm config set registry https://registry.npmmirror.com && npm install --omit=dev
# 复制构建产物
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/server-dist ./server-dist
# 暴露端口
EXPOSE 3000
ENV PORT=3000
ENV HOST=0.0.0.0
CMD ["node", "server-dist/server/index.js"]
# 运行开发服务器
CMD ["npm", "run", "dev", "--", "--port", "3000"]

7
docker-compose.yml Normal file
View File

@@ -0,0 +1,7 @@
services:
app:
build: .
container_name: copilot-toolbox-dev
restart: unless-stopped
expose:
- "3000"