我正在使用webpack使用内置的react app准备一个Docker映像。我可能会错过一些东西,因为执行yarn build
之后,我收到有关缺少Webpack的错误。但是我在node_modules/.bin/webpack
中有webpack,它是使用COPY . /web
$ webpack --mode production
/bin/sh: webpack: not found
error Command failed with exit code 127.
我只尝试运行yarn
,但是显然,这不会构建应用程序,但是我检查了容器以确认文件副本。
package.json
{
"name": "@mySweetApp/my-app",
"version": "0.0.1",
"description": "My Swee App",
"main": "./src/index.js",
"private": true,
"license": "MIT",
"scripts": {
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open --hot"
},
Dockerfile
FROM node:12.2.0-alpine as node
RUN mkdir -p /web
WORKDIR /web
#Copy dependency definition
COPY package.json /web
RUN yarn install
#Copy all files
COPY . /web
RUN yarn build
文件树(已删除不需要的东西)
},├── .babelrc
├── docker
│ ├── default.conf
│ ├── .dockerignore
│ └── ssl
├── Dockerfile
├── node_modules
│ ├── @babel
│ ├── babel-core
│ ├── .bin
│ │ ├── eslint -> ../../../../node_modules/eslint/bin/eslint.js
│ │ ├── eslint-config-prettier-check -> ../../../../node_modules/eslint-config-prettier/bin/cli.js
│ │ ├── lingui -> ../../../../node_modules/@lingui/cli/lingui.js
│ │ ├── lint-staged -> ../../../../node_modules/lint-staged/index.js
│ │ ├── webpack -> ../../../../node_modules/webpack/bin/webpack.js
│ │ ├── webpack-cli -> ../../../../node_modules/webpack-cli/bin/cli.js
│ │ └── webpack-dev-server -> ../../../../node_modules/webpack-dev-server/bin/webpack-dev-server.js
│ ├── .cache
│ ├── debug
│ ├── jsesc
│ ├── ms
│ └── source-map
├── package.json
├── src
└── webpack.config.js
我绝对想念这里的一些小东西,你能帮我吗?
答案 0 :(得分:0)
我可能已经解决了这个问题,我注意到那些符号链接指向父目录。我必须将dockerfile移动到其他目录,然后将更多文件复制到映像。 如果有任何成功,我会更新。