docker-compose build error for nodejs and yarn: [gpg: no valid OpenPGP data found.]

I have been trying to get a project to work for my job. I recently got a M1 Air, however I had a similar issues when I was doing the same thing on a Windows machine with WSL. The error is as follows:

 #8 8.455 ## To install the Yarn package manager, run:
#8 8.455 curl -sL | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
#8 8.455 echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] 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 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
#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 | bash - && apt-get install -y nodejs && curl -sS | apt-key add - && echo "deb 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

Has anyone experienced a similar thing? Here is my 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 && \ composer global require hirak/prestissimo
# node and yarn
RUN curl -sL | bash - && \ apt-get install -y nodejs && \ curl -sS | apt-key add - && \ echo "deb 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- /usr/local/etc/php-fpm.d/zzz-
COPY ./php.ini /usr/local/etc/php/php.ini
WORKDIR /work/backend

I tried a solution that I found by googling but ended up getting a different error that says:

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

I also posted for help on reddit a bit ago hoping to get a faster answer to my problem. Any help would be much appreciated!

1 Answer

SOLUTION: The problem was that the pubkey for the yarn package could not be read so the solution was to add this line.

RUN cat pubkey.gpg | apt-key add -

Thanks to VictorXLR on github.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like