Docker for development and gulp test errors
I think @mojavelinux missed each other a bit when we discussed setting up the build environment on gitter according to contributing.adoc
. I became confused...
- I ran
gulp test
and received some errors (not just failed tests) and thought this meant there was a problem with my installation environment. - Turns out these errors were side effects of what Dan diagnosed the issue to be -- a slower internet connection and the restrictions Mocha puts on finishing the tests within 2 seconds by default.
- At the time, from my perspective (inexperienced with Mocha and node and so on) it looked like I had two problems. (1) Failing tests and (2) a misconfigured build environment. I had focussed on (2) fatally not realising it was a consequence of (1).
So this MR adds a note about that based on Dan's comments.
Dan also thought some instructions on using Docker for development would be helpful and I said I'd have a go. My few lines within a Docker container turned out to be more complex than I thought they'd be to provide a useful set of instructions because:
- Docker does not allow volumes to be mounted from container --> host because it breaks container portability. The work around is messy (copy from container to host and then create a bind mount overwriting the container data) but it works. I thought of using the host environment for editing as a pre-requisite to writing helpful instructions (put others might be happy with an entire development environment within the container).
- Dan mentioned on gitter that running the container unprivileged was a good idea. And it is (although I've avoided doing it for other containers I've used...!) but there are consequences:
a. Making host and container uid/gids match up in Docker is problematic. In what I've produced if the host
uid=1000
everything works nicely, otherwise not so much. But I guess the user can just adjust theuid
if they're conscious of this. b. We could work around this by allowing the container to run as root. I'm happy to update this MR if you think running the container as root as OK -- I think that would make things simpler. -
nvm
relies on the use of shell scripts and is tied to bash but the default shell is dash. Fortunately there is now a command to change this,SHELL
to save messily symlinking fromsh
tobash
. - There's no obvious quick and clean way to eliminate the
NODE_VERSION
variable and the hard coded nvm version reference in the Dockerfile. Does it matter? I could put more effort into it if it was important. It would help if nvm would symlink saylatest
to the appropriate folder in.nvm/versions/node
.
At the end of this I think it works. MR on the way.
Happy to make changes/improvements.