# 使用 Node.js 镜像构建和运行应用 FROM node:lts-slim # 安装 git 和 ca-certificates RUN apt-get update && \ apt-get install -y --no-install-recommends git ca-certificates && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # 设置工作目录并克隆项目 WORKDIR /app ARG REPO_URL=https://github.com/HChaoHui/msOauth2api.git ARG BRANCH=vps RUN git clone -b ${BRANCH} ${REPO_URL} . COPY .env /app/ COPY apiRouters.js /app/routes/ # 安装 Yarn 依赖 RUN yarn install --frozen-lockfile # 暴露端口(根据 .env 文件,默认 9898) EXPOSE 9898 # 启动 Node.js 应用 CMD ["node", "app.js"]