Spaces:
raojl3
/
Sleeping

dfa / Dockerfile
ykl45's picture
Create Dockerfile
a4f16de verified
raw
history blame
908 Bytes
FROM node:lts AS BUILD_IMAGE
# 更新软件包列表并安装git
RUN apt-get update && apt-get install -y git
WORKDIR /app
# 拉取 GitHub 仓库
RUN git clone https://github.com/renqabs/dfa.git /app
# 安装依赖并构建项目
RUN yarn install --registry https://registry.npmmirror.com/ && yarn run build
FROM node:lts-alpine
# 从构建阶段复制构建输出、package.json 和 public目录
COPY --from=BUILD_IMAGE /app/dist /app/dist
COPY --from=BUILD_IMAGE /app/package.json /app/package.json
COPY --from=BUILD_IMAGE /app/public /app/public
WORKDIR /app
# 安装生产依赖
RUN yarn install --production --registry https://registry.npmmirror.com/
# 创建日志目录并授予写权限
RUN mkdir -p /app/logs && chmod 777 /app/logs
# 指定端口环境变量
ENV PORT 7860
# 暴露端口
EXPOSE $PORT
# 指定容器启动时执行的命令
CMD ["node", "dist/index.js", "--port", "7860"]