-
Notifications
You must be signed in to change notification settings - Fork 325
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 docker-build command #313
Conversation
Provides a "quick" way to compare the build output on "another" os
As always, writing up the PR notes has helped me think this through. The On a successful build the CI process would be configured to publish the image to the public docker registry along with the steps to run the container, extract the zip and and publish it to the various browser add-on registries. That'd be rad. |
Really cool! I think the issue of polluting host's Quick PoC: > mkdir -p node_modules_docker
> docker run -it --rm --name ipfs-companion-build -v "$PWD":/src -v "$PWD"/node_modules_docker:/src/node_modules -w /src node:8.9.1 /bin/bash -c "npm install && npm run build"
> du -sh node_modules*
218M node_modules
218M node_modules_docker We don't really care about Just for fun, another PoC, where > docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=300m,uid=1000 node_modules_tmpfs
> docker run -it --rm --name ipfs-companion-build -v "$PWD":/src -v node_modules_tmpfs:/src/node_modules -w /src node:8.9.1 /bin/bash -c "npm install && npm run build"
> docker volume rm node_modules_tmpfs |
i'll flip this pr to use the yarn.lock instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Provides a "quick" way to compare the build output on "another" os.
I'm trying to find a minimal way to use docker as a builder; to have a single command that installs the deps and runs the build in a container, and then ejects the final build artefact.
This PR adds an npm run script called
docker-build
that'll spin up a node:8.9.1 debian jessie based docker container. It runs
npm install && npm run build
in the container. The project dir on the host is mounted as a volume into the container, so the zip file is written to the build dir on the host machine, just as if the build had been run locally.There are some trade offs. It's simple to run, but the isolation is lower than you'd normally expect from a docker build. This means that your local node_modules dir will contain linux specific modules after running it, so you need to run a local npm rebuild to flip them back to your host os flavour. By being more selective with the mount config, we could probably avoid that, but i wanted to share this as is, to see if it's a reasonable idea.
The more dockery way would be to add a
Dockerfile
to the project. The process to get a bundle would then bemeanwhile... in another shell
# Copy the zip from the container to your local machine. docker cp ipfs-companion-builder:/src/build/ipfs_companion-2.0.15.zip ./build
Which seems way more cumbersome and manual...