I wanted to share with you all a Dockerfile that I put together over the weekend. I’m calling it “self-contained” because it doesn’t depend on the existence (or maintenance) of any Docker images besides ubuntu node and node:alpine. It’s a multistage Dockerfile, meaning that the final image is a lean, mean Alpine Linux image with your built server code, runtime dependencies, and nothing else.
Hope you find it useful, and feel free to suggest improvements or point out where I’ve gone wrong. I’m not very experienced with Docker although I’ve learned a lot through the process of getting this to work!
I haven’t experienced any Meteor errors with this setup. I’m not sure but I think it might have something to do with line 14 of your imports/startup/server/files.js. What’s happening on that line in your code?
As for memory usage, I’m not sure what’s causing it. I had assumed that it was mostly the Meteor app being built, but when I build the app on Windows I see that it only uses around 1 GB of RAM, not 2+. Not sure where the other memory usage is coming from.
I switched to Google Cloud Build which made memory issues no longer a worry. Hard to beat 120 free build minutes a day, too! The issue I wrestled with for a long time there was the default 10 minute build timeout; I finally figured out the cloudbuild.yaml setting that would increase that timeout, and added an example cloudbuild.yaml to the repo in case anyone else finds it useful.
I also swapped out the Ubuntu base image in the builder for a smaller Node image which may possibly reduce memory usage, and I did a bit of refactoring of the Dockerfile to reduce the number of intermediate containers.