.npmrc private registry not installing on deployment

Hi there, I am trying to deploy version of app that requires .npmrc file that authenticates with a private registry.

Specifically I am trying to use the @tiptap-pro/extension-emoji and I am getting 500 errors when trying run yarn install --frozen-lockfile

It is a rails 7 application. It only started having this issue when having to authenticate a private repository using yarn. All works locally as expected and the .npmrc authentication file works.

Here are the log files. Trying to deploy ASAP, if anyone knows how to resolve this that would be really helpful. Thanks!

==> Verifying app config
Validating /Users/georgekettle/code/georgekettle/taskmonkey/fly.toml
Platform: machines
✓ Configuration is valid
--> Verified app config
==> Building image
Remote builder fly-builder-dawn-waterfall-673 ready
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
[+] Building 49.9s (18/25)                                                                                                                  
 => [internal] load build definition from Dockerfile                                                                                   0.3s
 => => transferring dockerfile: 32B                                                                                                    0.3s
 => [internal] load .dockerignore                                                                                                      0.3s
 => => transferring context: 35B                                                                                                       0.3s
 => resolve image config for docker.io/docker/dockerfile:1                                                                             0.7s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021        0.0s
 => [internal] load build definition from Dockerfile                                                                                   0.0s
 => [internal] load metadata for docker.io/library/ruby:3.2.2-slim                                                                     0.3s
 => [internal] load .dockerignore                                                                                                      0.0s
 => [internal] load build context                                                                                                      0.3s
 => => transferring context: 20.91kB                                                                                                   0.3s
 => [base 1/3] FROM docker.io/library/ruby:3.2.2-slim@sha256:9654f1d43acae3032456fa89381076d3b997ea35d53259cf78a7db65b2e2121e          0.0s
 => CACHED [base 2/3] WORKDIR /rails                                                                                                   0.0s
 => [base 3/3] RUN gem update --system --no-document &&     gem install -N bundler                                                     4.8s
 => [build  1/10] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential curl libpq-dev node-gyp p  15.7s 
 => [stage-2 1/4] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y curl postgresql-client &&     rm -rf /var/  5.8s 
 => [build  2/10] RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ &&     /tmp/node-build-ma  3.9s 
 => [build  3/10] COPY --link Gemfile Gemfile.lock ./                                                                                  0.0s 
 => [build  4/10] RUN bundle install &&     bundle exec bootsnap precompile --gemfile &&     rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/c  17.5s 
 => [build  5/10] COPY --link package.json yarn.lock ./                                                                                0.0s 
 => ERROR [build  6/10] RUN yarn install --frozen-lockfile                                                                             6.5s 
------                                                                                                                                      
 > [build  6/10] RUN yarn install --frozen-lockfile:                                                                                        
#0 0.568 yarn install v1.22.19                                                                                                              
#0 0.606 [1/4] Resolving packages...                                                                                                        
#0 0.688 [2/4] Fetching packages...                                                                                                         
#0 1.173 error An unexpected error occurred: "https://registry.tiptap.dev/@tiptap-pro%2fextension-emoji/-/extension-emoji-2.2.1.tgz: Request failed \"500 Internal Server Error\"".                                                                                                     
#0 1.173 info If you think this is a bug, please open a bug report with the information provided in "/rails/yarn-error.log".
#0 1.173 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c yarn install --frozen-lockfile]: exit code: 1

Can you try changing that line in your Dockerfile to:

COPY --link .npmrc package.json yarn.lock ./

Thank you so much for your quick reply! This fixed it up :grinning:

Cool. I’ve made a change to dockerfile-rails so that .npmrc and .yarnrc files (if present) will be added to the COPY statement automatically when the Dockerfile is generated:

1 Like

Awesome, thanks man, I’m sure this will be helpful for others also