Join GitHub today
Packs not generated when using docker #1019
I have a rails 5.1.4 app with webpacker and react on rails gem.
The terminal shows that all files were compiled successfully
No files are created in the
I also tried putting the webpacker command
Update: I reinstalled webpacker and changed the host to 0.0.0.0 at the webpacker.yml
This is what is get:
@gauravtiwari Sure. You can see the log below.
When I disable the webpack-dev-server and use the lazy compilation, the packs are created without problems.
I changed inline to
With the following configuration it does not work:
Even if I change host to
I would like to use hmr, but it's better than nothing.
I had the same exact problems,
so I simply put
as a workaround.
Thank you, @Congrammers!
With the suggestion of a friend, what worked for us was to remove the webpacker from
@gauravtiwari @kairon-v I also had the same problem, in that when trying to run the webpack-dev-server from a container as part of a Docker Compose setup, I get a 404 on the
For reference, I managed to solve it by changing the host in
version: '3' services: webpacker: build: . command: bash -c "rm -rf /usr/src/app/public/packs; /usr/src/app/bin/webpack-dev-server" volumes: - .:/usr/src/app ports: - "3035:3035" postgres: image: postgres:9.6 ports: - "5432" app: build: . command: bash -c "rm /usr/src/app/tmp/pids/server.pid; bundle exec rails server -p 3000 -b '0.0.0.0'" volumes: - .:/usr/src/app ports: - "3000:3000" depends_on: - webpacker - postgres
dev_server: https: false host: webpacker # <-- this is necessary if running webpack-dev-server from another container! port: 3035 public: 0.0.0.0:3035 hmr: false # Inline should be set to true if using HMR inline: true overlay: true disable_host_check: true use_local_ip: false
Lastly, due to the new CSP stuff, I also had to update the CSP with a
Rails.application.config.content_security_policy do |p| p.default_src :self, :https p.font_src :self, :https, :data p.img_src :self, :https, :data p.object_src :none p.script_src :self, :https p.style_src :self, :https, :unsafe_inline # To allow connections to the webpack-dev-server running in # a separate docker container if Rails.env.development? p.connect_src :self, :https, 'http://localhost:3035', 'ws://localhost:3035', 'http://0.0.0.0:3035', 'ws://0.0.0.0:3035' end # Specify URI for violation reports # p.report_uri "/csp-violation-report-endpoint" end
I'm guessing having some kind of example like this would be helpful for others, seeing as it's taken me (as a long-time Rails dev, but webpack newbie) quite a while to figure out :)
I keep getting this error
I have been trying to fix it for 6 hours, but I need some help
I´m running on mac + docker
Here is my setup
And my docker-compose.yml
And my package.json
What am I missing here?
You need to change localhost to 0.0.0.0. An example working config:
dev_server: https: false host: 0.0.0.0 port: 3035 public: 0.0.0.0:3035 hmr: false # Inline should be set to true if using HMR inline: true overlay: true compress: true disable_host_check: true use_local_ip: false quiet: false headers: 'Access-Control-Allow-Origin': '*' watch_options: ignored: /node_modules/
For anyone else who lands here, I too was having an issue where only the
This would also happen after running
There is a file under
I found two potential solutions here
webpacker: <<: *base env_file: .env.development command: bash -c "rm -f tmp/cache/webpacker/.last-compilation-digest-development && bin/webpack-dev-server" ports: - '3035:3035'
I don't think either solution is that great as there must be a way to make use of docker's caching layer. Maybe a volume for the packs is the right way to go? Perhaps @gauravtiwari could weigh in? Does this need to be in webpacker's documentation?
Sorry for commenting on a closed issue but this took me a while to figure out so hopefully it can be helpful to someone else who lands here.
Ok - with a combination of the answers above, I was able to get a working project with rails in one container and webpacker in the second container. Arguably you can run the webpack-dev-server process in the same container, but I decided to not have to run that in the background, as to best take advantage of docker logging.
99% of the way there, the ONLY thing that isn't working is the HTTP request/WS request from the front-end to /sockjs-node/info?t=999 call.
relevant part of
Has anybody gotten the browser-reloading to work via this method? With host set to