StephenGrider / ReduxSimpleStarter

Starter pack for an awesome Udemy course

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dockerizing the project

elchivo1250 opened this issue · comments

This is not a question...more of a note to others.

I was trying to put this project into a docker container using docker-compose, and I ran into an issue viewing the page in my browser at http://localhost:8080. The browser was getting no response at all at that address. After a little investigation, I found that you need to add:

devServer: {
    ...
    host: "0.0.0.0",
    ...
}

to webpack.config.js to make the webpack dev server available externally. Hopefully this will save someone else a little headache.

Below are the config files for docker-compose in case anyone is interested. This is set up to put all project code in the ./app directory.

docker-compose.yml

version: "3"
services:
    app:
        image: node:9.11.1
        working_dir: /app
        volumes:
          - "./app:/app"
        ports:
            - "8080:8080"
        command: ["npm", "start"]

services.yml

version: "3"
services:
    test:
        image: node:9.11.1
        volumes:
            - "./app:/app"
        working_dir: /app
        entrypoint: ["npm", "run", "test", "--"]

    npm:
        image: node:9.11.1
        volumes:
            - "./app:/app"
        working_dir: /app
        entrypoint: "npm"
        command: "install"

Commands:
Run dev server: docker-compose up
NPM (default command is install): docker-compose -f services.yml run --rm npm [command]
Test: docker-compose -f services.yml run --rm test
Test watch: docker-compose -f services.yml run --rm test --watch

I also had to add the following line in the devServer declaration, because it was giving me a header mismatch error:
disableHostCheck: true,

Thanks, @aepod. Out of curiosity, at what point did you run into that error?

The app would come up, after the initial npm start, but you could not connect to it without the disableHostCheck. Running docker in a linux VM from the shell.