我正在通过简单的项目使用 docker 和 kubernetes 学习微服务,现在我正在尝试使用本地注册表安装为带有 helm 的 docker 容器。我在本地注册表中发布了我的包/库(我正在使用 verdaccio),并使用命令“npm install @mycompany/mylibs --registry=http://localhost:4873”将它成功安装在我当前的项目中。我的问题是当我尝试通过 skaffold 将我的项目部署到 kubernetes 时,它无法从 package.json 配置文件中下载包。我尝试将 .npmrc 文件设置到项目的根文件夹和 verdaccio conf 文件上的默认注册表,但都失败了。有没有人遇到过和我一样的问题以及如何解决。请有人帮忙。谢谢
这是我的项目结构:
MyProject
|-auth (this service has dependency to @mycompany/mylibs)
| |-src
| |-Dockerfile
| |-package.json
|
|-infra/kube
| |-auth-depl.yaml
| |-ingress-srv.yaml
MySharedLibrary
| |-src
| |-package.json
auth 的 package.json :
{
"name": "auth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node-dev src/index.ts",
"test": "jest --watchAll --no-cache"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"setupFilesAfterEnv": [
"./src/test/setup.ts"
]
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@mycompany/mylibs": "^1.0.3",
"@types/cookie-session": "^2.0.42",
"@types/express": "^4.17.9",
"@types/jsonwebtoken": "^8.5.0",
"cookie-session": "^1.4.0",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
"express-validator": "^6.7.0",
"jsonwebtoken": "^8.5.1",
"mariadb": "^2.5.1",
"mysql2": "^2.2.5",
"sequelize": "^6.3.5",
"ts-node-dev": "^1.0.0",
"typescript": "^4.1.2"
},
"devDependencies": {
"@types/jest": "^26.0.19",
"@types/supertest": "^2.0.10",
"jest": "^26.6.3",
"supertest": "^6.0.1",
"ts-jest": "^26.4.4"
}
}
我在用:
Windows 10 PC 作为 docker 的主要主机和项目托管的位置。
码头工人版本 19.03.13
npm 版本 6.14.6
维达乔 4.12.0
掌舵 3.5.3
脚手架 1.13.0
我部署项目后的错误消息skaffold dev:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@mycompany%2fmylibs - Not found
npm ERR! 404
npm ERR! 404 '@mycompany/mylibs@^1.0.3' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'app'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
我希望我的部署过程中每个容器都可以在本地注册表(http://localhost:4873)上找到所有必需的依赖项,当它找不到它们时,它应该尝试访问公共 npm(https://registry.npmjs.org或 npmjs.com)。