-
-
Save brianly/e5907ad453e9031da334d85cc0aec360 to your computer and use it in GitHub Desktop.
Easily build NodeJS projects inside a docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's a quick dockerfile: | |
----------------8<-------------[ cut here ]------------------ | |
FROM debian:latest | |
RUN apt-get update && apt-get install -y nodejs npm | |
----------------8<-------------[ cut here ]------------------ | |
save that as Dockerfile and do: docker build -t node-builder . | |
You can use this to build npm projects. For example: | |
$ git clone https://github.com/glowing-bear/glowing-bear.git | |
$ docker run -i -v `pwd`:/pwd -t node-builder | |
# cd /pwd/glowing-bear | |
# npm install webpack | |
# npm run build | |
exit and copy your build products out of the directory and you are done. | |
The best part is that I don't even have npm installed on my host at all. | |
None of the viruses in npm are able to run on my host when I do things this way. | |
Update: In fact we do not even need to make a dockerfile! Thanks to cepheus. | |
docker run -v `pwd`:/pwd -it node:16-buster-slim /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment