-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev-server inside docker? #59
Comments
I haven't tried this yet but one hint would be to treat your container like another named virtual host. If you are referencing them (containers) inside docker network use the container name, if it is from outside I think you will need to modify your /etc/hosts file to recognize the name you are using. Then, use the assets as you would like with a CDN. Look here at end this add the prefix you want with a know url. If this doesn't helps, please add more information, if possible, configuration files etc. Cheers |
Hey @davidmpaz, good thought. Doesn't work though. :( webpack.config.js: // .. rest of configuration
if (!Encore.isProduction()) {
Encore.setPublicPath('http://localhost');
Encore.setManifestKeyPrefix('/assets/build/');
} and got this error: (Note: same error regardless of hostname) |
@samjarrett lets try to separate issues. From:
I assume this is not related to Encore but with a development enviroment which can work without Encore. So my question are:
If so, next comes Encore troubleshooting. If not, then |
Hey @davidmpaz, actually it's an issue with how encore bundles a few webpack configuration items into one setting, which in a docker (or any remote dev style environment) you would hit an issue with. To recap the problem:
Encore doesn't provide a way of altering the config manually for the manifest plugin. If I was using standard webpack config I would easily be able to override that. |
Ok, sorry for not being of more help ;) Maybe @weaverryan has an idea on how this can be solve? |
Thanks for breaking this down guys. Indeed, you've described it perfectly: whwn you use dev-server, we automatically use whatever its host is as the publicPath (this affects the manifest.json paths but also internal paths in webpack in case you use code splitting). Once fix might be to allow you to set the publicPath while use the dev-server, but issue a warning on the terminal. We want to avoid someone setting a CDN URL (in production and dev) and not having things work when they use the dev-server. I think this would still cover that :) |
…ausk, weaverryan) This PR was merged into the master branch. Discussion ---------- Relaxed public path requirements with dev-server Fixes #59 and finishes #66. * Adds a new `--keep-public-path` option for `dev-server`. When used, your `publicPath` is not prefixed with the dev server URL. For #59, this means you can use `setPublicPath('/build')` with the dev-server, and your assets will remain local (i.e. `/build/main.js` instead of `http://localhost:8080/build/main.js`). * It is now possible to pass an absolute URL to `setPublicPath()` without an error when using `dev-server`. But, we issue a big warning, because this means your assets will point to to that absolute URL, instead of to the dev-server (which for most setups, is not what you want). @samjarrett I'd love to confirm that this would solve your issue in Docker :). Commits ------- 4bc1e19 Using real public path, though it doesn't look like it matters 92e22af Allowing an absolute publicPath with dev-server, but showing a warning 830fdb5 Adding --keep-public-path to dev-server to allow you to fully control the publicPath b27f7c9 Reversing some of the changes we won't do for now, and adding the failing test e206a12 fix issue in generated public path of manifest.json eb5565b convert error into warning 910b6bc convert error into warning
My project is based on a Docker and my container listen to the port 8088.
And my Yarn script is now (according to this comment) : It just works now ! 🎉 |
You can also check symfony/symfony-docs#11422 :) |
Hi,
I'm trying to get
encore dev-server
to work inside a docker container.I noticed at first that it listens only on the container's loopback interface ('localhost'), which was OK, because I could use
--host 0.0.0.0
to get it to listen on the proper network interface...But when I do this the manifest.json ends up using
http://0.0.0.0:8080/....
as it's url prefix, and this stops the assets from loading.I tried the
--public ...
flag to set a hostname for the public URL, but that doesn't seem to affect manifest generation.How can I do this?
Thanks.
The text was updated successfully, but these errors were encountered: