I moved my codebase to a dockereform file.
I have a file for building dockers using the command: command: bash -c "rm -rf node_modules && npm install && npm run dev"
and everything works fine, I use rm -rf node_modules because it gives me some errors of missing packages (from my MAC). By doing this, it simply recreates, and it works fine on the local host.
I also added volumes, so when I change something in my code, it is reflected in my container, this also works fine (except for a hot restart, but this is not very important).
Now I usually just comment out the line: command: bash -c "rm -rf node_modules && npm install && npm run dev" in my docker file and instead add: command: bash -c "rm -rf node_modules && npm install && npm run build" to build my package, so in production I donโt have a node at all, but it gives me no results.
Iโm not sure if this is a problem with volumes, that is, it is created in the container, but I canโt access it from my machine (which I donโt think because changing the code on my local machine is really reflected in my container), or for some reason it is not created at all.
This is the result of command: bash -c "rm -rf node_modules && npm install && npm run build --verbose"
NODE | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents): NODE | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3 : wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) NODE | NODE | added 115 packages in 11.036s NODE | npm info it worked if it ends with ok NODE | npm verb cli [ '/usr/local/bin/node', NODE | npm verb cli '/usr/local/bin/npm', NODE | npm verb cli 'run', NODE | npm verb cli 'build', NODE | npm verb cli '--verbose' ] NODE | npm info using npm@5.5.1 NODE | npm info using node@v9.2.0 NODE | npm verb run-script [ 'prebuild', 'build', 'postbuild' ] NODE | npm info lifecycle frontend@1.0.0 ~prebuild: frontend@1.0.0 NODE | npm info lifecycle frontend@1.0.0 ~build: frontend@1.0.0 NODE | NODE | > frontend@1.0.0 build /code/client NODE | > cross-env NODE_ENV=production webpack --progress --hide-modules NODE | NODE | Hash: cda5e46c2c7f4ba2903b NODE | Version: webpack 3.9.1 NODE | Time: 27298ms NODE | Asset Size Chunks Chunk Names NODE | build.js 1.29 MB 0 [emitted] [big] main NODE | build.js.map 7.65 MB 0 [emitted] main NODE | npm verb lifecycle frontend@1.0.0 ~build: unsafe-perm in lifecycle true NODE | npm verb lifecycle frontend@1.0.0 ~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/code/client/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE | npm verb lifecycle frontend@1.0.0 ~build: CWD: /code/client NODE | npm info lifecycle frontend@1.0.0 ~postbuild: frontend@1.0.0 NODE | npm verb exit [ 0, true ] NODE | npm info ok
And my webpack conf file starts as follows:
var path = require('path') var webpack = require('webpack') module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, '../static/dist/'), publicPath: '/dist/', filename: 'build.js' },
Which, at least before I worked perfectly, as my application looks like this:
- manage.py - static - dist - others - client - webpack.config.js
etc.
Why does nothing work in dist?
Update
I used exec to view the container. I can not find build.js anywhere. I also run touch abc.txt inside / code / static / dist, and it is also being created on my local host, that is, the volumes are working fine. This should be a web pack problem, not a docker.
Update 2
I also tried the full path, like this one, still nothing:
module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, '/code/static/dist'), publicPath: '/dist/', filename: 'build.js' },
Edit 3
I tried to find build.js. I found these files, but I think these are not my build.js:
root@0xxxxxx :/code