Skip to content
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

Cant run webpack-dev-server inside of a docker container? #547

Closed
ShashankaNataraj opened this issue Aug 4, 2016 · 9 comments
Closed

Cant run webpack-dev-server inside of a docker container? #547

ShashankaNataraj opened this issue Aug 4, 2016 · 9 comments

Comments

@ShashankaNataraj
Copy link

ShashankaNataraj commented Aug 4, 2016

Everything works fine when I want to run this through my local webpack server. I want to pack this project into a docker container.

The main page does get served with all the CSS assets intact, but none of the javascript within seems to have come through. I get this error message on my chrome console:

screen shot 2016-08-03 at 6 20 26 pm

My Dockerfile looks like this:

FROM node

# Prepare app directory
RUN mkdir -p /usr/src/app
ADD . /usr/src/app

# Install dependencies
WORKDIR /usr/src/app
RUN npm install

# Build the app
RUN npm build

# Expose the app port
EXPOSE "80:3000"
EXPOSE 885
EXPOSE 3001

# Start the app
CMD node build/server.js

Im using docker compose with the following config:

web:
  build: .
  ports:
    - '80:3000'
    - '885:885'
    - '3001:3001'
  command: npm start

Do I need to expose any other ports? Is there a workaround to this?

@SpaceK33z
Copy link
Member

Did you read "Webpack and Docker for Development and Deployment"? It explains the setup quite well.

@ShashankaNataraj
Copy link
Author

I just lifted over the .dockerfile and .dockerignore from that post and everything works now. Thanks for the tip!

@SpaceK33z
Copy link
Member

Cool! Could you close this issue?

@merapi
Copy link

merapi commented Mar 7, 2017

can be helpful for somebody:
change the binding address to 0.0.0.0

"start": "node_modules/.bin/webpack-dev-server --host 0.0.0.0",
or

  devServer: {
    host: '0.0.0.0',
    port: 80,
    ...
}

@kamil-kielczewski
Copy link

kamil-kielczewski commented Aug 8, 2018

@merapi what if I wanna use subdomains eg my-project.local:3002 (in my case I need to run many projects on different subdomains - each on different port) ?

@JeremyXu555
Copy link

can be helpful for somebody:
change the binding address to 0.0.0.0

"start": "node_modules/.bin/webpack-dev-server --host 0.0.0.0",
or

  devServer: {
    host: '0.0.0.0',
    port: 80,
    ...
}

works like a charm!!!

@nacengineer
Copy link

Did you read "Webpack and Docker for Development and Deployment"? It explains the setup quite well.

Linking to a paid article as the solution to a question in an open source forum, while understandable, is sus.

@jacrys
Copy link

jacrys commented Nov 5, 2020

Linking to a paid article as the solution to a question in an open source forum, while understandable, is sus.

As is not understanding that the web, and the resultant sites on there, change over time. In 2016, when this was written, Medium was not a subscription service, and subsequently, neither was this article. Medium went partially sub in 2017, doubled down in 2018 and 2019. I feel it would be more useful to the conversation for one to contribute a useful alternative for people finding this rather than criticizing someone for the current state of a contribution made 4 years ago in a landscape that evolves daily.

tacerihsehc613 referenced this issue in tacerihsehc613/eventful Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants