I've been playing around with setting some microservices in a Docker container where the service is based on Seneca.js. Since this is a Node.js application, I derived the container "FROM node". However, the container image is about 600 MB in size. Not exactly "micro". The eventual application will use a conglomerate of several such service and if each of them is 600+ MB in size, it will blow up the application to several GB.
Am I doing something wrong or is this how you'd go about setting up a Docker-Node.js-based microservice?
Thanks a lot.
Cheers,
Martin
Depending on how complicated your service is, you could build it directly off of alpine. An alpine node box at its most basic looks like this:
FROM alpine:latest
RUN apk update && apk add nodejs && rm -rf /var/cache/apk/*
This image is less than 25 MB. It also installs npm
of course, so you can install other dependencies or just mount package.json
into the working directory, or however else you might want to handle that.