docker - dockerfile:在多个存储库上运行工具
问题描述
我有一个 cli 工具,我正在使用 docker 创建一个 E2E 测试套件。基本思想是在 docker 容器中构建本地代码,然后在多个公共存储库上运行该工具。这样做的主要目的是更容易地查看我的 CLI 工具可能需要添加的任何缺失功能。
我确实设法让它工作,但由于所有的链接和文件夹管理,管理起来有点痛苦。
## Build a node application
from node:8.11.1
WORKDIR /app
## Copy all the files
COPY . ./sortier
## Build run and test
RUN cd ./sortier \
&& npm install --unsafe-perm \
&& npm run test \
&& cd .. \
## Run react-redux-typescript-guide/playground test
&& pwd \
&& git clone https://github.com/piotrwitek/react-redux-typescript-guide \
&& cd react-redux-typescript-guide/playground \
&& npm install --unsafe-perm \
&& echo "{ isHelpMode: true }" > .sortierrc \
&& cd ../../sortier \
&& npm run start -- "../react-redux-typescript-guide/playground/src/**/*.ts" \
&& npm run start -- "../react-redux-typescript-guide/playground/src/**/*.tsx" \
&& cd ../react-redux-typescript-guide/playground \
&& npm run build \
&& cd ../.. \
## Run prettier test
&& pwd \
&& git clone https://github.com/prettier/prettier \
&& cd prettier \
&& npm install --unsafe-perm \
&& echo "{ isHelpMode: true }" > .sortierrc \
&& cd .. \
&& npm run start -- "prettier/src/**/*.js" \
&& cd prettier \
&& npm run build \
&& npm run test \
&& cd ..
我试图弄清楚如何使用 WORKDIR 来更改目录,这将对其进行大量清理,但能够相互引用工作目录似乎不起作用。
关于如何清理这个 dockerfile 的任何建议?
解决方案
当然,在我发布问题后,我会找到答案(do'h)
## Build a node application
from node:8.11.1
## Sortier creation, build and test
WORKDIR /sortier
COPY . .
RUN npm install --unsafe-perm
RUN npm run test
## react-redux-typescript-guide/playground
WORKDIR /react-redux-typescript-guide
RUN git clone https://github.com/piotrwitek/react-redux-typescript-guide .
WORKDIR /react-redux-typescript-guide/playground
RUN npm install --unsafe-perm
RUN echo "{ isHelpMode: true }" > .sortierrc
WORKDIR /sortier
RUN npm run start -- "/react-redux-typescript-guide/playground/src/**/*.ts"
RUN npm run start -- "/react-redux-typescript-guide/playground/src/**/*.tsx"
WORKDIR /react-redux-typescript-guide/playground
RUN npm run build
RUN set CI=true&&npm run test
## prettier
WORKDIR /prettier
RUN git clone https://github.com/prettier/prettier
WORKDIR /prettier
RUN npm install --unsafe-perm
RUN echo "{ isHelpMode: true }" > .sortierrc
WORKDIR /sortier
RUN npm run start -- "/prettier/src/**/*.js"
WORKDIR /prettier
RUN npm run build
RUN npm run test
推荐阅读
- c# - 即使用户已登录,httpcontext 也将用户身份返回为 null,尝试为 hangfire 设置 authenticationfilter
- c - 无法将 Mingw-w64 正确添加到 Windows 8.1 上的路径
- python - 如何在不修改常量值和数据类型的情况下将结果存储在变量中
- java - 返回单链表的大小但不能使用head
- c++ - 为什么 VS 测试资源管理器不显示我的 C++ 自定义异常消息?
- r - RDSTK::street2coordinates 连接失败
- vue.js - Vuex 状态不会在 Vue 实例之间更新
- python - 从 csv 词频列表中删除重复项
- php - 将不同行的数据合并到一个单元格中
- reactjs - 样式化的组件算术运算