Files
agent/Dockerfile
2025-10-18 01:53:33 +00:00

40 lines
874 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 构建阶段 - 使用阿里云Node镜像
FROM node:20-alpine AS builder
# 设置工作目录
WORKDIR /app
# 配置npm使用淘宝镜像源解决国内网络问题
RUN npm config set registry https://registry.npmmirror.com
# 复制package.json和package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm install
# 复制项目文件
COPY . .
# 生产阶段 - 使用Node镜像运行Next.js应用
FROM node:20-alpine
# 设置工作目录
WORKDIR /app
# 配置Alpine使用国内镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 复制构建产物
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
# 安装生产依赖
RUN npm install --production
# 暴露Next.js默认端口
EXPOSE 3000
# 启动Next.js生产服务器
CMD ["npm", "start"]