Comments (5)
Our image extends the base image openshift/base-centos7
, which itself is 139MB compressed. We add 27MB to it to create a 166MB image. Which is essentially the size of node+npm and that's about it.
So you are right to say that stripping down the image would be good, but that means it will either need to happen as an upstream pull request on https://github.com/sclorg/s2i-base-container which is the repository that creates these base images, or we need to look elsewhere for a base image.
I poked around a little and found the Dockerfile
for openshift/base-centos7
here. As you can see, it adds a lot of stuff, but as I dig through it, and think about the work that any s2i image does, it seems there's not much that could be eliminated. Remember, Node.js apps may have native dependencies, and these need to get built by the s2i image during npm install
on creation of the output image. So we have to have things like gcc-c++
in these builder images.
This image, as you can see, extends centos7/s2i-core-centos7
, which is only about 80MB. So the stuff being installed by openshift/base-centos7
is about 50MB or so compressed.
I'm not sure how much space each of the installed packages require, and I'm not sure which ones are definitively needed for Node.js native modules. But as a quick back of the napkin sketch, here are a couple of things that might be removed:
And yes, using dnf
instead of yum
will probably reduce the image size as well.
We could potentially make our s2i image FROM centos7/s2i-core-centos7
, then use dnf
instead of yum
, duplicates most of what's in openshift/base-centos7
, but eliminates some of these seemingly unnecessary packages. I'm not sure how much that would reduce the size. At the moment, this is a bit of a low priority for me, but if you would like to submit a pull request, I'd be happy to take a look.
from centos7-s2i-nodejs.
Awesome, I will take a look to see if the size can be reduced.
from centos7-s2i-nodejs.
@cesarvr I also found information about "chained builds" in the openshift documentation. Using this would allow us to have both a builder image (our current centos7-s2i-nodejs image), and a runtime image that is considerably smaller.
The s2i image would be responsible for creating the runtime artifact - essentially the application source after npm install
has been run. And the second, chained builder image would be a stripped down image with only runtime essentials and the application itself installed.
Both paths of effort are useful, but this could be a better long-term strategy, perhaps.
from centos7-s2i-nodejs.
Hi @lance , I was having some fun and try to do my own image from scratch so I create this one cvaldezr/fedora-example (Fedora26).
If you want to give it a try just clone the current project and change the base image to point to cvaldezr/fedora-example and execute docker build --build-arg NODE_VERSION=6.11.2 -t sti-node-light .
, so you can test, for now Clang is not included for now.
final container:
centos/sti => 470 MB
cvaldezr/fedora-example => 197MB
I think there are still room for improvement :)
the "chained builds" in OSE is something I didn't hear before, but seems as the way to go achieve very thin final containers, but also, maybe it can take away the simplicity of S2i, not sure.
from centos7-s2i-nodejs.
With the move towards using our own base image, this task has become somewhat irrelevant
from centos7-s2i-nodejs.
Related Issues (20)
- Review / update CI config. HOT 1
- run `npm build` during assemble? HOT 2
- Update the doc to include the backport to master and publish the latest HOT 1
- To keep the publishing guide updated only on master branch ? HOT 1
- Investigate alternative ways to install debuginfo
- Investigate a better way to run npm build HOT 1
- node version 8.12.0 does "npm install -s --only=production" HOT 5
- check for "build" script, should also test for the existence of scripts HOT 2
- 8x update the sources to nodeshift github organization
- 10x update the sources to nodeshift organization
- 11x update the sources to nodeshift organization
- branch master: update to nodeshift organization
- squashed image is larger than original
- git-remote-https: error while loading shared libraries: libcurl-httpd24.so.4
- Wrong git tags HOT 3
- Support for webpack-dev-server in development mode HOT 2
- Yarn should be installed during s2i assemble phase HOT 2
- Consider moving this CI over to CircleCI instead of Travis-CI HOT 1
- Source Repo from Tutorial gone? HOT 1
- Red Hat uses this by default, so how can it be deprecated? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from centos7-s2i-nodejs.