我正在尝试对使用 vite 和 vue3 创建的前端应用程序进行 dockerize。它不作为容器工作。这是错误响应。
\n(!) 无法从 rollupOptions 或 html 文件自动确定入口点,并且没有显式的 OptimizeDeps.include 模式。跳过依赖项预捆绑。
\nVITE v3.2.4 ready in 191 ms\n\n \xc3\xa2\xc5\xbe\xc5\x93 Local: http://localhost:5173/\n \xc3\xa2\xc5\xbe\xc5\x93 Network: http://172.17.0.2:5173/\n(!) Could not auto-determine entry point from rollupOptions or html files and there are no explicit optimizeDeps.include patterns. Skipping dependency pre-bundling.\nRun Code Online (Sandbox Code Playgroud)\nDockerfile
\n# base image\nFROM node:16.3.0-alpine\n\n# set working directory\nWORKDIR /app\n\n# add `/app/node_modules/.bin` to $PATH\nENV PATH /app/node_modules/.bin:$PATH\n\n# install and cache app dependencies\nCOPY package.json /app/package.json\nRUN npm install\nRUN npm install @vue/cli@3.7.0 -g\n# start app\nCMD …Run Code Online (Sandbox Code Playgroud) 我有一个存储库,我想为其构建图像。那里有多个文件夹,我想排除一个名为“solver”的文件夹。使用 dockerignore 文件不是一个选项。
我努力了:
COPY ./[(^solver)] ./
COPY ./[(^solver)]* ./
COPY ./[^solver] ./
Run Code Online (Sandbox Code Playgroud)
然而这些都不起作用。
这篇文章中的第二个解决方案并没有解决我的问题。
我有一个 .dockerignore 文件,但对于一个用例,我想在命令行指定 .dockerignore 的内容,例如:
docker build --ignore="node_modules" -t foo .
Run Code Online (Sandbox Code Playgroud)
有没有办法从命令行执行此操作?我没有在文档中看到这一点:https : //docs.docker.com/engine/reference/commandline/build/#build-with--
我有一个 dockerfile,其中使用 alpine-nodejs 版本 16 作为基础映像。npm 版本是 8。
npm install --production当执行的步骤时docker build,它还会安装 package.json 的 dev-dependencies 下列出的依赖项,这与生产标志的用例相反。我也用过npm install --only=production,但似乎也不起作用。
在 alpine nodejs 版本 14 中,该标志按预期工作,并且开发依赖项未安装在容器中。alpine 节点版本 16 镜像有问题吗?谢谢。
我需要在第一阶段排除 Docker COPY 中的文件,但在第二阶段的另一个 COPY 中使用它,因为它会破坏 Docker 层缓存。
我的文件夹结构如下:
src/
public/
.env
package.json
nginx.conf
Run Code Online (Sandbox Code Playgroud)
我的 Dockerfile 如下所示:
FROM node:14 as builder # line-1
WORKDIR /app # line-2
COPY . /app # line-3 nginx.conf is copied but not needed
RUN yarn && yarn build # line-4
FROM nginx:1.21.1 # line-5
WORKDIR /app # line-6
COPY --from=builder /app/build /app/build # line-7
COPY nginx.conf /app # line-8 nginx.conf is copied
CMD nginx -c /app/nginx.conf # line-9
Run Code Online (Sandbox Code Playgroud)
当我更改nginx.confdocker 层缓存时,由于第三行,缓存变得无效。
我无法使用,.dockerignore因为它会在两个阶段都忽略它。 …
docker ×5
dockerfile ×5
alpine-linux ×1
docker-copy ×1
docker-image ×1
docker-layer ×1
npm ×1
npm-install ×1
vite ×1
vuejs3 ×1