Using Alpine for Mud
• Mark Eschbach
Alright, I have a bit of time to crack the issue with the Docker build. In a Github issue they make reference to using the following:
RUN apk add --no-cache --virtual .build-deps alpine-sdk python \ && npm install --production --silent \ && apk del .build-deps
So that kind of worked. Except for the fact I wanted NPM to be installed as the
node user. So I came up with the
following to work on it. So, on to the dance!
FROM node:10.4.1-alpine ENV NDOE_ENV=production RUN apk add --no-cache --virtual /tmp/.build-deps alpine-sdk python WORKDIR /app ADD *.js *.json /app/ RUN chown -R node:node /app USER node RUN npm install --production --silent USER root RUN apk del /tmp/.build-deps USER node EXPOSE 12345 CMD ["node", "cli.js", "omni"]
Well that worked well. No the only problem is the number of layers created as a result. If I remember correctly there
is a flag on the build command to collapse all of these layers.
would be it. This took the image size from 325 MBs to 119 MBs, a lot more reasonable. I wish this was a closer to the
52 MBs on disk of my laptop but I will take it for now. Alright, the layer containing the system is only 52 MBs, I am
totally willing to take that one.
There are some additional details which need to be cleaned up such as signal handling for termination. Probably placing a health check and documenting where the actual data is stored would be a good idea too. Maybe provide some extension points. But those are problems for another day.
At least some Travis builds I have worked on recently did not support it due to having an older version of
Docker. I wonder if that has been fixed. I think for now I’ll not worry about automatically building and pushing
Docker images into Docker Hub since I will need to figure out stages with
sudo builds. I’ll just push
myself for now.