我正在尝试用vue3构建一个vite.js项目。我想在Dockerfile中构建它,但是我得到了以下错误。
vite v2.9.5 building for production...
✓ 0 modules transformed.
Could not resolve entry module (index.html).
error during build:
Error: Could not resolve entry module (index.html).
at error (/panda-planner/frontend-planner/node_modules/rollup/dist/shared/rollup.js:198:30)
at ModuleLoader.loadEntryModule (/panda-planner/frontend-planner/node_modules/rollup/dist/shared/rollup.js:22480:20)
at async Promise.all (index 0)
Error response from daemon: The command '/bin/sh -c npm run build' returned a non-zero code: 1
Failed to deploy '<unknown> Dockerfile: Dockerfile': Can't retrieve image ID from build stream
我一直在寻找关于汇总的信息,但我不明白它是什么。另外,我的命令npm run build
在我的计算机上运行得很好。
有人能帮帮我吗?
我的vite.config.js
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import eslintPlugin from "vite-plugin-eslint";
const path = require("path");
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), eslintPlugin()],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
});
我的文件
# Build backend application
FROM node:14.19.1-alpine AS builder
WORKDIR /panda-planner/backend-planner/
COPY /backend-planner/package*.json .
RUN npm install
COPY . .
RUN npm run build
EXPOSE 1337
CMD ["npm", "run", "start" ]
# Build frontend application
FROM builder as frontend
WORKDIR /panda-planner/frontend-planner/
COPY /frontend-planner/package*.json .
RUN npm install --legacy-peer-deps
COPY . .
RUN npm run build
# Setup nginx server for frontend
FROM nginx:stable-alpine as nginx
COPY --from=frontend /frontend-planner/dist /usr/share/nginx/html
#COPY ./default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;" ]
发布于 2022-04-21 09:04:07
我的坏处.!
我在前面的复制路径上犯了一个错误。
这个解决方案的工作原理是:
# Build backend application
FROM node:14.19.1-alpine AS builder
WORKDIR /panda-planner/backend-planner/
COPY /backend-planner/package*.json .
RUN npm install
COPY /backend-planner/ .
RUN npm run build
EXPOSE 1337
CMD ["npm", "run", "start" ]
# Build frontend application
FROM builder AS frontend
WORKDIR /panda-planner/frontend-planner/
COPY /frontend-planner/package*.json .
RUN npm install --legacy-peer-deps
COPY /frontend-planner/ .
RUN npm run build
# Setup nginx server for frontend
FROM nginx:stable-alpine AS nginx
COPY --from=frontend /panda-planner/frontend-planner/dist/ /usr/share/nginx/html/
#COPY ./default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;" ]
https://stackoverflow.com/questions/71912584
复制相似问题