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

[New] Introduce Docker environment for nvm #1472

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

PeterDaveHello
Copy link
Collaborator

This should help nvm development and testing

@ljharb
Copy link
Member

ljharb commented Apr 2, 2017

This definitely belongs in a separate repo; I don't use Docker myself and can't commit to maintaining it. Separately, a docker file for developing nvm will rapidly be misused as a docker file for using nvm, and that won't be good for anybody.

@PeterDaveHello
Copy link
Collaborator Author

hmmm ... we still have problem on running tests locally, I believe that docker can help in this part. As nvm is under a person account not an organization account, I'm not sure how to make it separated, or maybe just be unofficial, but for the local testing works, it'll be definitely good to use docker to isolate the environment with very low overhead and complexity IMO, what do you think?

@PeterDaveHello
Copy link
Collaborator Author

PeterDaveHello commented Apr 2, 2017

The reason of this PR 😅 : #1339 (comment)

I'd be happy to review adding one, but I don't use any of those tools myself.

@ljharb
Copy link
Member

ljharb commented Apr 2, 2017

Regardless of docker or no, the tests need to be fixed so they can be run and pass locally regardless of NVM_DIR location.

Also, Mac OS X is one of the most important platforms for nvm, and that can't be tested with docker; which means that id rather perfect the generic dev story before focusing on a container one.

You are correct about that comment, and I appreciate the PR. I will leave it open, but do not plan to merge it in the medium term.

@PeterDaveHello
Copy link
Collaborator Author

I thought there is a PR trying to add MacOS test in Travis CI already, there should be no conflicts about testing on MacOS and adding Dockerfile, am I right?
I think it's better to have a isolated environment for testing, not only working directory, it won't take the focus or mess up the development work, but will only make it cleaner.

@PeterDaveHello
Copy link
Collaborator Author

As it's for development environment usage, the docker image will be 1.3GB fat and it needs about 15 mins to be built, not thin and not quick at all, so I don't agree that it will rapidly be misused as a docker file for using nvm, it makes no sense.

@ljharb
Copy link
Member

ljharb commented Apr 2, 2017

Fair points. I don't think these files need to be downloaded by users who install nvm using git, though. Can you think of a way to avoid that?

@PeterDaveHello
Copy link
Collaborator Author

PeterDaveHello commented Apr 2, 2017

If you wanna do that, yes, we can use sparseCheckout, and we should checkout only nvm-exec, nvm.sh & bash_completion, other files aren't needed, agree?

@ljharb
Copy link
Member

ljharb commented Apr 2, 2017

I'd prefer an exclusion list approach, rather than an inclusion list approach - git updating needs to grab new file by default, so that i can split things up into separate files in the future.

Can we use sparseCheckout and check out everything except certain folders?

@PeterDaveHello
Copy link
Collaborator Author

Nope I don't think so.

@ljharb
Copy link
Member

ljharb commented Apr 2, 2017

Then we'll need another solution, I think.

@PeterDaveHello
Copy link
Collaborator Author

I think we just don't need to be so afraid of misusing, should we? They have no reason to misuse it :)

@PeterDaveHello PeterDaveHello force-pushed the Dockerfile branch 4 times, most recently from 85340ca to ef6537d Compare April 2, 2017 07:44
@@ -0,0 +1,17 @@
HEAD
.cache
v*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about versions/?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be also ignored as expected

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh duh, because it starts with v. k

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go now?

.urchin_stdout
test/**/test_output

node_modules/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't docker already ignore everything in .gitignore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

Dockerfile Outdated
#
# This is for development usage only, please not that it'll use about
# 1.2 GB disk space and about 15 minutes to build this image, and this
# is not a Dockerfile to build a Dockerized nvm for production usage.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added notes here to remind people not to misuse it.

@PeterDaveHello PeterDaveHello force-pushed the Dockerfile branch 7 times, most recently from e03ea3d to 5fe9e3a Compare April 2, 2017 08:11
@PeterDaveHello
Copy link
Collaborator Author

btw @ljharb, I think we can update sparseCheckout in each versions' install script if you really need that, not a problem at all

@PeterDaveHello
Copy link
Collaborator Author

Actually I just found that this really really help me debug nvm problems, as it's purely isolated and I can spawn multi containers to test at the same time, which saved me many hours, hope we can give it a try, make the contribution easier for the others.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What command would I run to test this out locally?

RUN echo 'export PATH="~/.cabal/bin/:${PATH}"' >> $HOME/.bashrc

# nvm
COPY . /home/nvm/.nvm/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is /home/nvm a path for inside the docker image?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's inside docker.

@PeterDaveHello
Copy link
Collaborator Author

@ljharb try docker build -t nvm . at the root of nvm, then you'll have a docker image named nvm, if you need it be tagged like tagged commit as version in git, try docker build -t nvm:version .

Use docker images to get the result, it'll looks like:

REPOSITORY         TAG                 IMAGE ID            CREATED             SIZE
nvm                latest              9ca4c57a97d8        7 days ago          1.22 GB

@PeterDaveHello
Copy link
Collaborator Author

Docker images published here: https://hub.docker.com/r/peterdavehello/nvm/ wtih v0.33.2 tag.

@PeterDaveHello
Copy link
Collaborator Author

@ljharb is there anything else I can do here? Thanks.

@ljharb
Copy link
Member

ljharb commented Jun 26, 2017

Is there any value in constraining this to a docker subdirectory?

@PeterDaveHello
Copy link
Collaborator Author

@ljharb do you mean you're considering to put it in a docker folder? I don't think we need to do that as our root is the same the repo root.

@ljharb
Copy link
Member

ljharb commented Jun 26, 2017

Yes, so that docker-related files don't clutter up the main repo root.

@PeterDaveHello
Copy link
Collaborator Author

I'm not sure if it has some value, as we are not going to build production environment with many different base like nodejs would build with different operating systems which would need to be separated.

Personally, the current status looks good enough to me.

@ljharb ljharb merged commit 3ac49e5 into nvm-sh:master Jun 28, 2017
@PeterDaveHello PeterDaveHello deleted the Dockerfile branch June 28, 2017 09:16
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