1

I'm trying to deploy my app on fly.io.

The problem I have is that it uses private packages from GitHub Packages registry.

  "dependencies": {
    "@myscope/mypackage": "^1.0.1",
    ...
  }

I have a .npmrc file that works well when using npm on my local machine, but does not seems to be detected by fly.io. It is used to define the URL and auth key to get those packages.

//npm.pkg.github.com/:_authToken=mytoken
@myscope:registry=https://npm.pkg.github.com

When I fly deploy, we can see that the package is searched on npmjs and not on Github:

  #8 2.129 npm ERR! code E404
  #8 2.131 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@myscope%2fmypackage - Not found
  #8 2.132 npm ERR! 404 
  #8 2.132 npm ERR! 404  '@myscope/2fmypackage@^1.0.1' is not in this registry.

first attempt

try to force include the .npmrc file in fly.toml by adding

[build]
  include = [".npmrc"]
  buildpacks = [  "npmrc",  "nodejs"]

= not working.

second attempt

After some researches on github, I attempted to tweak my Dockerfile and fly.toml files :

Dockerfile

...
ARG GITHUB_TOKEN
RUN npm config set @spiff-radio:registry https://npm.pkg.github.com \
  && npm config set "//npm.pkg.github.com/:_authToken" '${GITHUB_TOKEN}' \
  && npm i --production \
  && npm config delete "//npm.pkg.github.com/:_authToken"

# Install dependencies
RUN npm install
...

fly.toml

[env]
GITHUB_TOKEN = "mytoken"

= not working either.

Could someone help me ? Thanks !

gordie
  • 1,637
  • 3
  • 21
  • 41

0 Answers0