dekart icon indicating copy to clipboard operation
dekart copied to clipboard

make target "docker" fails due to missing .npmrc

Open allenday opened this issue 2 years ago • 8 comments

Makefile target "docker" Dockerfile requires .npmrc: https://github.com/dekart-xyz/dekart/blob/main/Makefile#L23 https://github.com/dekart-xyz/dekart/blob/main/Dockerfile#L5

However, this file is excluded by .gitignore: https://github.com/dekart-xyz/dekart/blob/main/.gitignore#L40

Proposed solution:

  • add a file "npmrc"
  • modify Dockerfile to COPY the file to .npmrc

Here's the error from make docker:

npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR!     https://www.npmjs.com/forgot
npm ERR! 
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR!     npm login
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-02-09T18_01_07_946Z-debug.log

allenday avatar Feb 09 '22 18:02 allenday

Hey @allenday please check the docs to build from source https://dekart.xyz/docs/contributing/build-from-source/

delfrrr avatar Feb 09 '22 21:02 delfrrr

Thanks @delfrrr . I've done this, and granted permissions repo, workflow, write:packages, but still seeing the same error.

Contents of my .npmrc look like this:

//npm.pkg.github.com/:_authToken=ghp_XXXXXXXXXX
@dekart-xyz:registry=https://npm.pkg.github.com

allenday avatar Feb 10 '22 14:02 allenday

Do some other commands such as: https://github.com/dekart-xyz/www/blob/main/content/docs/contributing/build-from-source.md?plain=1#L48 also need to be added to the Dockerfile?

allenday avatar Feb 10 '22 14:02 allenday

@allenday can you please confirm if npm install is completing/failing on your local? (see steps)

Also can you please confirm which step fails in docker build?

Please note that root Dockerfile is used to build dekart docker image before publishing it; it is used for CI/CD workflow and it executes successfully https://github.com/dekart-xyz/dekart/runs/4893074528?check_suite_focus=true

These are steps to build frontend in Dockerfile

FROM node:16 as nodebuilder
WORKDIR /source
ADD package.json . //copy your package.json
ADD package-lock.json . //copy your package-lock.json
ADD .npmrc . //copy your package-lock.json .npmrc
RUN npm i // does this command fails?
ADD public public
ADD src src
RUN npm run build

You are not expected to modify Dockerfile. You don't need yo copy .env into the Docker; environment variable are provided when you run the container https://github.com/dekart-xyz/dekart/tree/main/install/docker

.env is used only for local development

delfrrr avatar Feb 11 '22 06:02 delfrrr

Correct, the failure is at the "npm i" step.

On Fri, Feb 11, 2022 at 14:56 Vladi Bilonenko @.***> wrote:

@allenday https://github.com/allenday can you please confirm if npm install is completing/failing on your local? (see steps https://dekart.xyz/docs/contributing/build-from-source/)

Also can you please confirm which step fails in docker build?

Please note that root Dockerfile is used to build dekart docker image before publishing it; it is used for CI/CD workflow https://github.com/dekart-xyz/dekart/blob/main/.github/workflows/release.yaml and it executes successfully https://github.com/dekart-xyz/dekart/runs/4893074528?check_suite_focus=true

These are steps to build frontend:

FROM node:16 as nodebuilder WORKDIR /source ADD package.json . //copy your package.json ADD package-lock.json . //copy your package-lock.json ADD .npmrc . //copy your package-lock.json .npmrc RUN npm i // does this command fails? ADD public public ADD src src RUN npm run build

— Reply to this email directly, view it on GitHub https://github.com/dekart-xyz/dekart/issues/26#issuecomment-1035927468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADKOP24ULLU4GYJNP7ZSG3U2SXINANCNFSM5N6HT4LA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

allenday avatar Feb 11 '22 09:02 allenday

FYI I'm also now experiencing the same problem for gcloud app deploy, whereas I was previously able to deploy without issue.

allenday avatar Feb 14 '22 06:02 allenday

hey @allenday ; I've launched VM instance on GCP and went through setup steps on it successfully using friend's GitHub token (to make sure there is no permission problem);

System Info: Linux instance-1 4.19.0-18-cloud-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux

These are my steps starting from empty instance

# git
sudo apt install git-all
git clone https://github.com/dekart-xyz/dekart.git
cd dekart/

# .npmrc
vim .npmrc # content as mentioned above

# setting up node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
nvm install 16

# testting npm install
npm install # works

# docker
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo   "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world # testing docker
sudo make docker # works

delfrrr avatar Feb 19 '22 08:02 delfrrr

@allenday if you do experience problem, and build failed inside the docker I can only assume that problem is with your .npmrc file:

  • wrong path
  • wrong token

let me know if I can do anything else here

delfrrr avatar Feb 19 '22 08:02 delfrrr

Hi @allenday! I am following up on the above, are you still facing some issues?

kevinjamesparks avatar Mar 02 '23 20:03 kevinjamesparks