我正在为nuxt 3应用程序构建一个对接环境.这是我的package.json
%文件:
{
"private": true,
"scripts": {
"start": "nuxt start",
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"prepare": "husky install",
"prepare:hook": "husky add .husky/commit-msg \"npx --no -- commitlint --edit $1"
},
"dependencies": {
"nuxt": "3.0.0-rc.6"
},
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@commitlint/types": "^17.0.0",
"@formkit/nuxt": "1.0.0-beta.9",
"@formkit/themes": "1.0.0-beta.9",
"@formkit/vue": "1.0.0-beta.9",
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
"@pinia/nuxt": "^0.3.0",
"@swisscom/sdx": "file:./sdx",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"eslint": "^8.19.0",
"eslint-plugin-nuxt": "^3.2.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.2.0",
"husky": "^8.0.1",
"luxon": "^3.0.1",
"pinia": "^2.0.16",
"prettier": "2.7.1",
"sass": "^1.53.0",
"typescript": "^4.7.4",
"vue": "^3.2.37"
}
}
这是我的docker-compose.yml
%文件:
services:
app:
build:
context: .
dockerfile: Dockerfile
args:
- NPM_TOKEN=${NPM_TOKEN}
- NPM_MAIL=${NPM_MAIL}
restart: always
ports:
- '3000:3000'
env_file:
- .env
depends_on:
- db
db:
image: mongo
restart: always
ports:
- 27017:27017
volumes:
- smap_db:/usr/db/smap
environment:
MONGO_INITDB_ROOT_USERNAME: ${DB_USER}
MONGO_INITDB_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
smap_db:
external: true
这是我对Nuxt 3应用程序的Dockerfile
分:
# Dockerfile
FROM node:18.6.0-bullseye
ARG NPM_TOKEN
ARG NPM_MAIL
# Set working directory
WORKDIR /usr/bin/smap
# Install dependencies
COPY .npmrc package.json sdx ./
RUN npm install
RUN rm -f .npmrc
# Copy the app
COPY . .
RUN npm run build
EXPOSE 3000
ENV NUXT_HOST=0.0.0.0
CMD [ "npm", "start" ]
这是我的.dockerignore
%文件:
# Dependencies
node_modules
# Editor
.vscode
# Build outputs
.nuxt
.output
dist
# Commitlint
.husky
commitlint.config.ts
# Other
README.md
当我运行docker compose up
时,我在构建docker文件时得到以下错误:
=> ERROR [7/7] RUN npm run build 0.8s
------
> [7/7] RUN npm run build:
#0 0.796
#0 0.796 > build
#0 0.796 > nuxt build
#0 0.796
#0 0.803 /tmp/build6594337338.sh: 2: nuxt: not found
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 127
以下是我到目前为止试图解决的问题:
- 已删除与我的应用程序关联的所有容器、卷等,然后重新构建所有内容
- 将坞站重置为出厂设置
- 停用构建工具包功能
- comments 了
.dockerignore
名中的每一件事 - 已try 使用NODE的以下映像版本:
-
node:18.6.0-bullseye
个 -
node:18.6.0
个 -
node:18.6.0-alpine
个 -
node:18
个
-
所有这些都没有帮助,我总是得到相同的错误.
为什么在坞站容器内找不到nuxt
命令?我做错什么了吗?有人知道我怎么解决这个问题吗?
更新
我把NPM_CONFIG_LOGLEVEL
调到了info
.错误仍然是相同的,但有一些附加信息:
=> ERROR [8/8] RUN npm run build 1.7s
------
> [8/8] RUN npm run build:
#0 1.641 npm info using npm@8.15.0
#0 1.642 npm info using node@v18.7.0
#0 1.642 npm timing npm:load:whichnode Completed in 0ms
#0 1.643 npm timing config:load:defaults Completed in 2ms
#0 1.643 npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 5ms
#0 1.643 npm timing config:load:builtin Completed in 6ms
#0 1.643 npm timing config:load:cli Completed in 1ms
#0 1.644 npm timing config:load:env Completed in 1ms
#0 1.644 npm timing config:load:file:/usr/bin/smap/.npmrc Completed in 2ms
#0 1.644 npm timing config:load:project Completed in 5ms
#0 1.644 npm timing config:load:file:/root/.npmrc Completed in 0ms
#0 1.644 npm timing config:load:user Completed in 1ms
#0 1.645 npm timing config:load:file:/usr/local/etc/npmrc Completed in 6ms
#0 1.645 npm timing config:load:global Completed in 6ms
#0 1.645 npm timing config:load:validate Completed in 2ms
#0 1.645 npm timing config:load:credentials Completed in 1ms
#0 1.645 npm timing config:load:setEnvs Completed in 1ms
#0 1.645 npm timing config:load Completed in 28ms
#0 1.645 npm timing npm:load:configload Completed in 28ms
#0 1.645 npm timing npm:load:mkdirpcache Completed in 1ms
#0 1.645 npm timing npm:load:mkdirplogs Completed in 1ms
#0 1.645 npm timing npm:load:setTitle Completed in 1ms
#0 1.646 npm timing config:load:flatten Completed in 2ms
#0 1.646 npm timing npm:load:display Completed in 9ms
#0 1.653 npm timing npm:load:logFile Completed in 7ms
#0 1.653 npm timing npm:load:timers Completed in 0ms
#0 1.654 npm timing npm:load:configScope Completed in 0ms
#0 1.656 npm timing npm:load Completed in 50ms
#0 1.667
#0 1.667 > build
#0 1.667 > nuxt build
#0 1.667
#0 1.675 /tmp/build-27aedcc8.sh: 1: nuxt: not found
#0 1.677 npm timing command:run Completed in 15ms
#0 1.678 npm timing npm Completed in 74ms
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 127