harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
949 stars 56 forks source link

unable to use within docker container #208

Open Vaiune opened 3 months ago

Vaiune commented 3 months ago

Describe the bug

Hey,

We implemented this module with our app and it worked great locally but when we needed to deploy to production via docker, our CI failed ( see docker build logs below for a fresh project with only seo module installed ) to build the image.

x64 linux host

Sending build context to Docker daemon  135.7kB
Step 1/6 : FROM node:20-alpine
 ---> ae7f6c370720
Step 2/6 : COPY / /
 ---> 58565d83a83e
Step 3/6 : RUN npm install -g pnpm
 ---> Running in b71f2229b305

added 1 package in 781ms

1 package is looking for funding
  run `npm fund` for details
npm notice
npm notice New minor version of npm available! 10.2.4 -> 10.5.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>
npm notice Run `npm install -g npm@10.5.0` to update!
npm notice
Removing intermediate container b71f2229b305
 ---> 9d255473a93c
Step 4/6 : WORKDIR "/"
 ---> Running in 598c786369e6
Removing intermediate container 598c786369e6
 ---> 49a6fe9737e1
Step 5/6 : RUN pnpm install
 ---> Running in 167d1ca5418d
Progress: resolved 1, reused 0, downloaded 0, added 0
Progress: resolved 968, reused 0, downloaded 884, added 0
Packages: +928
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1012, reused 0, downloaded 928, added 585
Progress: resolved 1012, reused 0, downloaded 928, added 928, done
.../fontawesome-common-types postinstall$ node attribution.js
.../node_modules/vue-demi postinstall$ node -e "try{require('./scripts/postinstall.js')}catch(e){}"
.../fontawesome-common-types postinstall: Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com
.../fontawesome-common-types postinstall: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
.../fontawesome-common-types postinstall: Copyright 2023 Fonticons, Inc.
.../fontawesome-common-types postinstall: Done
.../node_modules/vue-demi postinstall: Done
.../@fortawesome/free-regular-svg-icons postinstall$ node attribution.js
.../@fortawesome/free-solid-svg-icons postinstall$ node attribution.js
.../esbuild@0.20.2/node_modules/esbuild postinstall$ node install.js
.../esbuild@0.19.12/node_modules/esbuild postinstall$ node install.js
.../@fortawesome/free-solid-svg-icons postinstall: Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com
.../@fortawesome/free-solid-svg-icons postinstall: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
.../@fortawesome/free-solid-svg-icons postinstall: Copyright 2023 Fonticons, Inc.
.../@fortawesome/free-regular-svg-icons postinstall: Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com
.../@fortawesome/free-regular-svg-icons postinstall: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
.../@fortawesome/free-regular-svg-icons postinstall: Copyright 2023 Fonticons, Inc.
.../@fortawesome/free-solid-svg-icons postinstall: Done
.../@fortawesome/free-regular-svg-icons postinstall: Done
.../esbuild@0.20.2/node_modules/esbuild postinstall: Done
.../esbuild@0.19.12/node_modules/esbuild postinstall: Done
.../node_modules/json-editor-vue preinstall$ node -e "if (process.env.INIT_CWD === process.cwd()) { process.exit(1) }" || npx only-allow pnpm
.../node_modules/json-editor-vue preinstall: Done
.../node_modules/json-editor-vue postinstall$ node -e "if (process.env.INIT_CWD === process.cwd()) { process.exit(1) }" || npx simple-git-hooks
.../node_modules/json-editor-vue postinstall: Done

> nuxt-app@ postinstall /
> nuxt prepare

 ERROR  Cannot find matching package.json in / or parent directories

  at findFile (/node_modules/.pnpm/pkg-types@1.0.3/node_modules/pkg-types/dist/index.mjs:45:9)

 ERROR  Cannot find matching package.json in / or parent directories

 ELIFECYCLE  Command failed with exit code 1.
The command '/bin/sh -c pnpm install' returned a non-zero code: 1

arm64 m2 mac

 => ERROR [5/6] RUN pnpm build                                                                                                                             0.8s
------
 > [5/6] RUN pnpm build:
0.337
0.337 > nuxt-app@ build /
0.337 > nuxt build
0.337
0.482 Nuxt 3.11.0
0.801
0.801  ERROR  Cannot find module @rollup/rollup-linux-arm64-musl. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i again after removing both package-lock.json and node_modules directory.
0.801
0.801   at requireWithFriendlyError (/node_modules/.pnpm/rollup@4.13.0/node_modules/rollup/dist/native.js:87:9)
0.801   at Object.<anonymous> (/node_modules/.pnpm/rollup@4.13.0/node_modules/rollup/dist/native.js:96:76)
0.801   at Module._compile (node:internal/modules/cjs/loader:1376:14)
0.801   at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
0.801   at Module.load (node:internal/modules/cjs/loader:1207:32)
0.801   at Module._load (node:internal/modules/cjs/loader:1023:12)
0.801   at cjsLoader (node:internal/modules/esm/translators:356:17)
0.801   at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
0.801   at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
0.801   at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
0.801
0.801
0.801
0.801  ERROR  Cannot find module @rollup/rollup-linux-arm64-musl. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i again after removing both package-lock.json and node_modules directory.
0.801
0.806  ELIFECYCLE  Command failed with exit code 1.
------
Dockerfile:6
--------------------
   4 |     WORKDIR "/"
   5 |     RUN pnpm install
   6 | >>> RUN pnpm build
   7 |
--------------------
ERROR: failed to solve: process "/bin/sh -c pnpm build" did not complete successfully: exit code: 1

The Dockerfile in essence

FROM node:20-alpine
COPY / /
RUN npm install -g pnpm
WORKDIR "/"
RUN pnpm install
RUN pnpm build

Reproduction

create fresh nuxt project, add seo and try to build with docker

System / Nuxt Info

node:20-alpine image (tried different versions and distros)
fresh nuxt 3.11 project with seo module added
harlan-zw commented 3 months ago

This is not related to this module, you can see the issue is from the binary files for Rollup being incorrect for the platform.

You need to force install the dependencies if you're re-installing in a different platform as it needs to download different binaries than what are in your lock file.

pnpm i --force
Vaiune commented 3 months ago

Thanks for the suggestion, didnt think of that. I tried that and now we are looking at the same error on both architectures that it was the case for x64, any input?

 > [base  9/12] RUN pnpm install --force:
32.03 
32.03  ERROR  Cannot find matching package.json in / or parent directories
32.03 
32.03   at findFile (/node_modules/.pnpm/pkg-types@1.0.3/node_modules/pkg-types/dist/index.mjs:45:9) 
32.03 
32.03 
32.03 
32.03  ERROR  Cannot find matching package.json in / or parent directories
32.03 
32.05  ELIFECYCLE  Command failed with exit code 1.
creazy231 commented 2 months ago

same problem over here

#10 0.383 yarn install v1.22.22
#10 0.490 [1/5] Validating package.json...
#10 0.495 [2/5] Resolving packages...
#10 1.194 [3/5] Fetching packages...
#10 2.132 error Error: https://npm.fontawesome.com/@fortawesome/free-regular-svg-icons/-/6.5.2/free-regular-svg-icons-6.5.2.tgz: Request failed "401 Unauthorized"