Nodejs 和 YARN 的 docker-compose 建置錯誤:[gpg:找不到有效的 OpenPGP 資料。

Nodejs 和 YARN 的 docker-compose 建置錯誤:[gpg:找不到有效的 OpenPGP 資料。

我一直在努力讓一個專案適合我的工作。我最近購買了 M1 Air,但是當我使用 WSL 在 Windows 電腦上執行相同的操作時,我遇到了類似的問題。錯誤如下:

    #8 8.455 ## To install the Yarn package manager, run:
#8 8.455      curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
#8 8.455      echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
#8 8.455      sudo apt-get update && sudo apt-get install yarn
#8 8.455
#8 8.455
#8 8.455 + apt-get install -y nodejs
#8 8.462 Reading package lists...
#8 8.805 Building dependency tree...
#8 8.871 Reading state information...
#8 8.942 The following NEW packages will be installed:
#8 8.942   nodejs
#8 9.093 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
#8 9.093 Need to get 24.5 MB of archives.
#8 9.093 After this operation, 121 MB of additional disk space will be used.
#8 9.093 Get:1 https://deb.nodesource.com/node_14.x buster/main arm64 nodejs arm64 14.18.2-deb-1nodesource1 [24.5 MB]
#8 12.29 debconf: delaying package configuration, since apt-utils is not installed
#8 12.30 Fetched 24.5 MB in 3s (7,533 kB/s)
#8 12.32 Selecting previously unselected package nodejs.
(Reading database ... 23271 files and directories currently installed.)
#8 12.33 Preparing to unpack .../nodejs_14.18.2-deb-1nodesource1_arm64.deb ...
#8 12.33 Unpacking nodejs (14.18.2-deb-1nodesource1) ...
#8 13.92 Setting up nodejs (14.18.2-deb-1nodesource1) ...
#8 13.94 + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg
#8 13.94 + apt-key add -
#8 13.97 Warning: apt-key output should not be parsed (stdout is not a terminal)
#8 14.39 gpg: no valid OpenPGP data found.
------
executor failed running [/bin/bash -oeux pipefail -c curl -sL https://deb.nodesource.com/setup_14.x | bash -  &&   apt-get install -y nodejs &&   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-get update && apt-get install yarn]: exit code: 2
ERROR: Service 'app' failed to build : Build failed

有人也經歷過類似的事情嗎?這是我的 dockerfile。

FROM php:7.4-fpm-buster
SHELL ["/bin/bash", "-oeux", "pipefail", "-c"]

# timezone environment
ENV TZ=UTC \
  # locale
  LANG=en_US.UTF-8 \
  LANGUAGE=en_US:en \
  LC_ALL=en_US.UTF-8 \
  # composer environment
  COMPOSER_ALLOW_SUPERUSER=1 \
  COMPOSER_HOME=/composer \
  # Laravel environment
  APP_SERVICES_CACHE=/tmp/cache/services.php \
  APP_PACKAGES_CACHE=/tmp/cache/packages.php \
  APP_CONFIG_CACHE=/tmp/cache/config.php \
  APP_ROUTES_CACHE=/tmp/cache/routes.php \
  APP_EVENTS_CACHE=/tmp/cache/events.php \
  VIEW_COMPILED_PATH=/tmp/cache/views

COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer

RUN apt-get update && \
  apt-get -y install git libicu-dev libonig-dev libzip-dev unzip locales libpq-dev libpng-dev libjpeg-dev libfreetype6-dev imagemagick libmagickwand-dev && \
  pecl install imagick && \
  docker-php-ext-enable imagick && \
  docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && \
  docker-php-ext-install -j$(nproc) gd pdo pdo_pgsql && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* && \
  locale-gen en_US.UTF-8 && \
  localedef -f UTF-8 -i en_US en_US.UTF-8 && \
  mkdir /var/run/php-fpm && \
  mkdir -p /tmp/cache/views && \
  chmod 777 -R /tmp/cache && \
  docker-php-ext-install intl pdo_mysql zip bcmath && \
  composer config -g process-timeout 3600 && \
  composer config -g repos.packagist composer https://packagist.org && \
  composer global require hirak/prestissimo

# node and yarn
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -  && \
  apt-get install -y nodejs && \
  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-get update && apt-get install yarn

RUN yarn global add secure-spreadsheet

COPY ./php-fpm.d/backend-www.conf /usr/local/etc/php-fpm.d/zzz-www.conf
COPY ./php.ini /usr/local/etc/php/php.ini

WORKDIR /work/backend

我嘗試了我找到的解決方案谷歌搜尋但最終得到了一個不同的錯誤:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: dockerfile parse error line 41: unknown instruction: APT-GET ERROR: Service 'app' failed to build : Build failed

我也會發文尋求幫助紅迪特不久前希望能更快回答我的問題。任何幫助將非常感激!

答案1

解決方案:問題是無法讀取紗線包的公鑰,因此解決方案是添加此行。

RUN cat pubkey.gpg | apt-key add -

感謝 VictorXLRgithub

相關內容