Mud Simple Entry Point
• Mark Eschbach
Tests have proven Mud can startup and work as expected. Now for the next fun event: packaging for deployment. Not that the system is in a particularly glamorous place with shiny new paint but better to release early and often.
First up is building an entry point which makes the system easy to boot up. Should be fairly straight forward. Might need some refactoring though.
Resolving Relatives Paths
An interesting issue I have not had the pleasure of dealing with in NodeJS yet is relative path resolution. Turns out this is actually really simple. Invoke Path.relative/2 and there you go. Does this work with absolutes though? Let us try.
const path = require("path"); console.log( path.relative( process.cwd(), "/tmp" ) );
Me thinks I did it wrong. And it is because you are to use Path.resolve/n. Well at least that is simpler. Now the question is ordering.
const path = require("path"); console.log( path.resolve( process.cwd(), "/tmp" ) );
Sweet. Exactly what I desired.
This feeds into the calculation of the storage locations for the system. So you can specify the
fs-root option and it
will default to calculating relatives paths. Or you can specify full paths to the relevant storage options and
everything will resolve to the specified location.
Building a Container
Building a NodeJS Alpine image is fairly straight forward. A pet peeve of mine is not pinning dependencies, so going
for the full triple dot is simple:
node:10.4.1-alpine. Pretty easy.
Or so I thought. There are two issues. The recommend user is actually
node. Easy enough to fix:
ADD *.js *.json /app/ RUN chown -R node:node /app USER node
The next part is interesting. When running
RUN npm install the following error message is generated:
npm ERR! code ENOGIT npm ERR! Error while executing: npm ERR! undefined ls-remote -h -t https://github.com/meschbach/js-junk-drawer.git
This is effectively complaining Git isn’t installed within the container. I think the easiest solution is to release
junk-drawer has been registered
in NPM for quiet some time.
Registering a package with NPM
I think at some point I registered a package with NPM or at least I intended to. I have an account at least! But no packages uploaded. Time to get cracking on that.
To resolve the name conflict I’ll be changing it to
junk-bucket since I’ve been carting it around with me. Not sure
if I want to change the repository yet though, so I am hoping just the package name change should be enough.
> npm login Username: meschbach Password: Email: (this IS public) Logged in as meschbach on https://registry.npmjs.org/. > npm publish
Well that was simple enough. So simple I published two version with cleaned up metadata. At some point I should really get Travis setup for that project. Anyway, popping the problem off the stack and on to the real task at hand.
Doh! Ran out of time. I will have to complete this project a different time.