如何解决在 Docker 文件上安装 yarn global
我正在尝试让 yarn 和 docker 镜像识别一个全局包。
FROM ruby:2.7.2
RUN apt-get update -qq && apt-get install -y nodejs libvips-tools yarn
# Install all gems first.
# This hits the warm cache if unchanged so bundling is faster.
copY Gemfile* /tmp/
workdir /tmp
RUN bundle install
workdir /sapco
copY . /sapco
# Get yarn and install global required packages
RUN yarn global add mjml
EXPOSE 3000
# Start the main process.
CMD ["rails","server","-b","0.0.0.0"]
我用 docker build -f Dockerfile.dev .
我收到以下错误:
=> [internal] load build deFinition from Dockerfile.dev 0.0s
=> => transferring dockerfile: 504B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load Metadata for docker.io/library/ruby:2.7.2 1.2s
=> CACHED [1/8] FROM docker.io/library/ruby:2.7.2@sha256:abe7034da4092958d306c37aded76a751ea9d35d5c90d1ad9e92290561bd5f3f 0.0s
=> [internal] load build context 0.4s
=> => transferring context: 220.47kB 0.4s
=> [2/8] RUN apt-get update -qq && apt-get install -y nodejs libvips-tools yarn 38.2s
=> [3/8] copY Gemfile* /tmp/ 0.1s
=> [4/8] workdir /tmp 0.0s
=> [5/8] RUN bundle install 292.6s
=> [6/8] workdir /sapco 0.0s
=> [7/8] copY . /sapco 0.5s
=> ERROR [8/8] RUN yarn global add mjml 0.7s
------
> [8/8] RUN yarn global add mjml:
#12 0.567 Parsing scenario file global
#12 0.568 ERROR: [Errno 2] No such file or directory: 'global'
解决方法
问题是 yarn 与 cmdtest
提供的另一个二进制文件同名
我最终将其追溯到 https://github.com/yarnpkg/yarn/issues/2821
并解决了我在 Dockerfile 中运行此命令的问题。
apt remove -y cmdtest
apt remove -y yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update
apt install yarn
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。