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

Adds Dockerfile and docker-compose.yml to project #47

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

scotthelm
Copy link

First off, thank you for a fantastic course! It has helped me understand not only React and Redux, but a great deal more about the node ecosystem than I could have hoped.

I do most of my development in a docker environment. The Dockerfile and docker-compose.yml included in this PR allow me to follow the course using containers. This allows me to keep my system uncluttered with installations, and gives me a repeatable development environment. I have a Dockerfile and docker-compose.yml for the auth-server as well. That allowed me to avoid installing mongo on my host system, and only bring it up when running docker-compose up.

If you have the docker tools installed (Docker, Docker Machine, Docker Compose), the following steps would get you up and running:

$ docker-compose run --rm app npm install
$ docker-compose up

These commands will pull the required images and create new ones from the Dockerfile. The up command starts webpack dev server. (I have it on port 8100 as there was a conflict with another service on my machine, but this port is totally changeable).

To install packages, you can use the run command and add --save the-package-name to the end.

The Dockerfile modifies the container's chown command so that it plays nice with when node tries to own all the files (the code here basically fakes node out so it thinks it owns them all after install).

Thanks for your time, and I hope you find this useful.

@demiladef
Copy link

Hey thanks for dockerizing this, it was really helpful as I tried doing it myself for almost two days to no success. Can you walk me through how the Dockerfile works, especially from line 5 and on.

RUN echo "int chown() { return 0; }" > \ preload.c && \ gcc -shared -o /libpreload.so \ preload.c && \ rm preload.c ENV LD_PRELOAD=/libpreload.so

Cheers

@scotthelm
Copy link
Author

npm tries to own everything it pulls down. This causes problems in an environment where you're dealing with volume mounts in docker. So to get around this, you substitute a placebo command for chown that does nothing. Npm is happy because it thinks it did it's job, and we're happy because it didn't. This is not my original idea - I searched around until I found this original comment.

Hope that helps!

@demiladef
Copy link

Yeah it really does, thanks!

devOTTO pushed a commit to devOTTO/ReduxSimpleStarter that referenced this pull request Jul 7, 2019
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

Successfully merging this pull request may close these issues.

2 participants