2024-08-09 15:08:29 +08:00
|
|
|
|
# 使用官方的 Node.js 镜像作为基础镜像
|
|
|
|
|
FROM node:18
|
2024-08-08 13:29:13 +08:00
|
|
|
|
|
2024-08-09 15:08:29 +08:00
|
|
|
|
# 设置工作目录
|
2024-08-08 13:29:13 +08:00
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2024-08-09 15:08:29 +08:00
|
|
|
|
# 复制 package.json 和 package-lock.json(如果有)到工作目录
|
|
|
|
|
COPY package*.json ./
|
2024-08-08 13:29:13 +08:00
|
|
|
|
|
2024-08-09 15:08:29 +08:00
|
|
|
|
# 安装依赖
|
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
|
|
# 复制项目的源代码到工作目录
|
2024-08-08 13:29:13 +08:00
|
|
|
|
COPY . .
|
|
|
|
|
|
2024-08-09 15:08:29 +08:00
|
|
|
|
# 暴露服务端口
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
# 启动应用程序
|
2024-08-09 10:51:34 +08:00
|
|
|
|
CMD ["npm", "start"]
|