【发布时间】:2019-08-18 00:16:20
【问题描述】:
这里是 Docker 和 Docker 容器的新手。
我正在尝试了解如何从我的 bitbucket-pipeline 进程运行映像中的脚本。
关于我在哪里的一些背景和一些知识
在 Bitbucket-Pipelines 步骤中,您可以添加任何图像以在该特定步骤中运行。例如,我已经尝试过并且没有问题的工作是获取像 alpine:node 这样的图像,这样我就可以在我的管道脚本中运行 npm 命令:
definitions:
steps:
- step: &runNodeCommands
image: alpine/node
name: "Node commands"
script:
- npm --version
pipelines:
branches:
master:
- step: *runNodeCommands
这意味着 master 分支上的每次推送都将运行一个构建,其中使用 alpine/node 映像我们可以运行像 npm --version 这样的 npm 命令并安装包。
我做了什么
现在我正在使用一个自定义容器,我在其中安装了一些节点包(如 eslint)来运行命令。 IE。 eslint file1.js file2.js
太棒了!
我正在尝试但不知道如何
我有一个本地 bash 脚本 awesomeScript.sh,在我的存储库中有一些输入参数。所以我的bitbucket-pipelines.yml 文件看起来像:
definitions:
steps:
- step: &runCommands
image: my-user/my-container-with-eslint
name: "Running awesome script"
script:
- ./awesomeScript.sh -a $PARAM1 -e $PARAM2
pipelines:
branches:
master:
- step: *runCommands
我在不同的存储库中使用相同的awesomeScript.sh,我想将该功能移到我的 Docker 容器中并在存储库中删除该脚本
如何构建我的 Dockerfile 以便能够在我使用 docker 映像的“任何地方”运行该脚本?
PS:
我一直在考虑构建一个 node_module,像 eslint 模块一样在 Docker Image 中安装该模块......但我想知道这是否可能
谢谢!
【问题讨论】:
标签: docker continuous-integration dockerfile bitbucket-pipelines