Running au run in a brand new, default app in a docker container doesn’t expose the app over mapped ports because the app is listening on localhost rather than 0.0.0.0, but changing the platform.host setting in aurelia.json doesn’t seem to have any effect.
To get the app to listen on 0.0.0.0, I had to change webpack.config.js.
Before you replace host with 0.0.0.0, can you log the value of host? Some docker script might have passed a value to --host which overshadows project.platform.host in expression host || project.platform.host.
You’ve added the Dockerfile manually, or you have gone through the “Custom Aurelia App” setup of the cli? If it’s the latter can you share which configurations you’ve chosen? Or tell me the steps to reproduce the problem?
FYI, the stackoverflow issue has recieved a reply: https://stackoverflow.com/a/58685079/664217
They have changed the value in webpack.config.js rather than in aurelia.json.
This is not anything with Aurelia, it is webpack that needs to change the host. I’ve answered on the stack question, just pass the —host 0.0.0.0 to the au run command.
au run --host 0.0.0.0 did fix the problem without changing the webpack.config.js, which is good.
My question is, shouldn’t changing aurelia.json change the default setting, so I don’t have to use a command line argument? If not, is there a good way to change the default setting and what’s the purpose of aurelia.json?
Someone asked about my docker file and how I created the app. Here’s my Dockerfile:
FROM node
RUN npm install -g aurelia-cli
WORKDIR /app
EXPOSE 8080
CMD /bin/bash
And I created the app, with au new and selected all the defaults, i.e. npm and ESNext. I think that should be enough to let you recreate it.
OK, I got something wrong. Nothing to do with docker. Here is the log of host without explicit --host. Note the logged webpack command: webpack-dev-server --extractCss
⋊> ~/p/w au run
Local aurelia-cli v1.2.1
Starting 'run'...
`au run` is an alias of the `npm start`, you may use either of those; see README for more details.
> w@0.1.0 start /Users/huocp/playground/w
> webpack-dev-server --extractCss
host: localhost
project.platform.host: 127.0.0.1
ℹ 「wds」: Project is running at http://localhost:8080/
Somehow, the webpack config got localhost as the value of host, that means project.platform.host is never honoured in host || project.platform.host.
webpack-dev-server fills up some default value to webpack config. It adds host with value localhost when user didn’t explicitly set in command line.
This is annoying, our host || project.platform.host never worked.
The funny thing is webpack-dev-server only mutates the options passed to webpack config. Whether the user uses that passed in host value inside devServer config, it’s totally up to the user. This is beyond my comprehension of design.
It looks that @huochunpeng resolved the issue; about the Dockerfile, I see no problem in that, except that it is kind of development-like Dockerfile, for more information regarding this matter please check out here and here