使用docker映像时缺少已安装的依赖项

使用docker映像时缺少已安装的依赖项,docker,continuous-integration,dockerfile,continuous-deployment,github-actions,Docker,Continuous Integration,Dockerfile,Continuous Deployment,Github Actions,这是我的文件 FROM node:10 RUN apt-get -qq update && apt-get -qq -y install bzip2 RUN yarn global add @bluebase/cli && bluebase plugins:add @bluebase/cli-expo && bluebase plugins:add @bluebase/cli-web RUN bluebase plugins 构建docke

这是我的文件

FROM node:10

RUN apt-get -qq update && apt-get -qq -y install bzip2

RUN yarn global add @bluebase/cli && bluebase plugins:add @bluebase/cli-expo && bluebase plugins:add @bluebase/cli-web
RUN bluebase plugins

构建docker文件时,它会安装所有依赖项,最后一个命令
RUN bluebase plugins
输出已安装插件的列表。但是当这个映像被推送到github操作中使用时,
bluebase
在全球范围内可用,但没有安装插件。我做错了什么

Github工作流

name: Development CI

on:
  push:
    # Sequence of patterns matched against refs/heads
    branches:
      - '*' # Push events on all branchs
      - '*/*'
      - '!master' # Exclude master
      - '!next' # Exclude next
      - '!alpha' # Exclude alpha
      - '!beta' # Exclude beta

jobs:
web-deploy:
    container: 
      image: hashimsohail/bluebase-image
    name: Deploy Web
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1

      - name: Check BlueBase
        run: bluebase #Outputs list of comamnds available with bluebase

      - name: Check BlueBase Plugins
        run: bluebase plugins #Outputs no plugins installed


我不认为与图像的问题,它很容易在本地图像确认,你会看到插件是在Docker图像可用

FROM node:10

RUN apt-get -qq update && apt-get -qq -y install bzip2

RUN mkdir -p /github/home
ENV HOME /github/home

RUN yarn global add @bluebase/cli && bluebase plugins:add @bluebase/cli-expo && bluebase plugins:add @bluebase/cli-web
RUN bluebase plugins
试着跑吧

docker build -t plugintest .
#then run the image on local system to verify plugin
docker run -it --rm --entrypoint "/bin/sh" plugintest -c "bluebase plugins"
您的YML配置文件似乎存在问题

      image: hashimsohail/bluebase-image
    name: Deploy Web
    runs-on: ubuntu-latest
这一行
运行于:ubuntu最新版本
没有意义,我认为应该是这样

运行于:ashimsohail/bluebase image

这是一个棘手的问题!这是对我有效的解决方案。我将尝试在下面解释原因

jobs:
  web-deploy:
    container:
      image: hashimsohail/bluebase-image
    name: Deploy Web
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Check BlueBase
        run: bluebase
      - name: Check BlueBase Plugins
        run: HOME=/root bluebase plugins
      - name: Check web plugin
        run: HOME=/root bluebase web:build --help
背景

首先是码头工人形象。命令
bluebase plugins:add
似乎非常依赖于
$HOME
环境变量。您的Docker映像构建为
root
用户,因此
$HOME
/root
bluebase plugins:add
命令在
$HOME/.cache/@bluebase
安装插件依赖项,因此它们最终位于
/root/.cache/@bluebase

现在是
jobs..container
功能。当您的容器运行时,会发生一些相当复杂的Docker网络和卷装载。其中一个挂载是
-v”/home/runner/work/\u temp/\u github\u home:“/github/home”
。这会将主机中的本地文件(包括签出存储库的副本)装载到容器中。然后它将
$HOME
更改为指向
/github/HOME

问题

bluebase插件不起作用的原因是它依赖于指向
/root
$HOME
,但现在GitHub操作将其更改为
/GitHub/HOME

解决方案

我尝试的一个解决方案是将插件安装在Docker映像中的
/github/home
而不是
/root

FROM node:10

RUN apt-get -qq update && apt-get -qq -y install bzip2

RUN mkdir -p /github/home
ENV HOME /github/home

RUN yarn global add @bluebase/cli && bluebase plugins:add @bluebase/cli-expo && bluebase plugins:add @bluebase/cli-web
RUN bluebase plugins
问题是GitHub操作创建的卷装载会覆盖
/GitHub/home
目录。因此,我尝试了一些技巧,比如符号链接或移动
.cache/@bluebase
目录,以避免它被挂载撞到。这些都不起作用

因此,唯一的解决方案似乎是将
$HOME
改回
/root
。这不应该在工作流中永久完成,因为GitHub操作依赖于
HOME=/GitHub/HOME
才能正常工作。因此,解决方案是为每个命令临时设置它

HOME=/root bluebase web:build --help
外卖


这一点的主要好处是,在容器中预先构建的任何工具,如果依赖于指向特定位置的
$HOME
,在
作业中使用时,可能无法正常工作。
容器语法。

github中的运行没有覆盖dockerfile中的运行吗?它无法覆盖,第一个run命令只检查是否全局安装,另一个应该打印已安装插件的列表,因此,我可以进一步讨论流程。参考官方文档中只有一个有限的运行选项列表。您确认了我提到要测试的插件了吗?尽管
docker run-it--rm--entrypoint”/bin/sh“pluginest-c”bluebase plugins的输出
显示插件列表是的,当我在本地运行映像时会打印该列表。因此,这已确认是github yml配置的问题,而不是docker映像的问题。您能帮助我增加此docker映像中的观察者吗?我收到了这个错误
sysctl:setting key“fs.inotify.max_user_watches”:只读文件系统
恐怕我不知道怎么做。也许最好提出一个新问题,因为它不再是同一个问题了。