-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce size of container image #6
Comments
Hey - that's a great point - the node dependencies are very minimal (i.e. no @errordeveloper - could you kindly give me a rough guide to getting a node equivalent to the iojs minimal container or should I just use the iojs one do you think? I was also thinking that I should base wait-for-weave on busybox as its only a binary mounted in a volume. |
If it's statically linked you could use scratch as the base. That's what the weave router does. |
@binocarlos I'd be more then happy if you test out the IO.js container @squaremo referred to. In the meantime I had been making progress on a tooling container that would allow one to rebuild a customised version of that container I used for IO.js. Right now it just gets the tarball of the 1.0.1 release... Please do take this only as a functional prototype, and if you are interested to chat more about building thin runtime-only containers for Node, do ping me over email. |
@errordeveloper that sounds great! It's not that often I find the need for I'll test out |
Hey guys quick question regarding wait-for-weave - I've changed the binary to be statically linked but am patently learning as I go(lang) so could you check my build command is OK:
from the Makefile and largely inspired by this thread I'm not sure that the The code uses the However - the above works and I've changed the base image to be many thanks - sorry for noob questions :-) |
@binocarlos could you show the source code of the |
@errordeveloper no probs it lives here And I've pasted it here: package main
import (
"os"
"os/exec"
"fmt"
"github.com/zettio/weave/net"
)
const WEAVE_INTERFACE_NAME = "ethwe"
const WAIT_FOR_SECONDS = 10
const QUIT_IMMEDIATELY_VAR = "WAIT_FOR_WEAVE_QUIT"
/*
get the cli arguments as an array and remove the
first element leaving us with the intended entrypoint
then run that entrypoint attaching stdin, stdout and stderr
*/
func runEntryPoint() {
entryPoint := make([]string, len(os.Args))
copy(entryPoint, os.Args)
// remove blocker from args[0]
entryPoint = append(entryPoint[:0], entryPoint[1:]...)
// get and remove the actual command from args[0]
commandString := entryPoint[0]
entryPoint = append(entryPoint[:0], entryPoint[1:]...)
cmd := exec.Command(commandString, entryPoint...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}
/*
If the ethwe interface is not found after 10 seconds then write to stderr and exit with non-zero code
*/
func main() {
/*
this is so we can run an initial version of this container making its volumes available
to other containers using --volumes-from
*/
quitFlag := os.Getenv(QUIT_IMMEDIATELY_VAR)
if quitFlag == "yes" {
fmt.Fprintln(os.Stdout, "exiting without waiting because WAIT_FOR_WEAVE_QUIT == yes")
os.Exit(0)
}
if _, err := net.EnsureInterface(WEAVE_INTERFACE_NAME, WAIT_FOR_SECONDS); err != nil {
a := fmt.Sprint("interface ", WEAVE_INTERFACE_NAME, " not found after ", WAIT_FOR_SECONDS, " seconds")
fmt.Fprintln(os.Stderr, a)
os.Exit(1)
} else {
runEntryPoint()
}
} |
Hey guys, so - I'm having trouble because I realise that there is more than just a node app inside the container - notably (from the Dockerfile) there is:
So - I'm not sure what other dependencies there are regarding the weave bash script doing its magic. @errordeveloper I have had success using the That works because there is nothing but a node app inside the container. Are there any ways to use another image but keep the above dependencies for this adapter? |
Have just found these comments by @rade which are relevant considering this image includes weave |
At the minute the Dockerfile bases its image on
node:0.10
, which is notionally reasonable since that's what it needs. However, that base image contains a huge amount of extra guff that's not needed at runtime (it's based itself on debian), and ends up being 700-odd MB.There are
node:*-slim
images that are a bit smaller, but I think better still would be to use a container to get the dependencies, then copy those and the runtime out into another container. @errordeveloper has done this elsewhere for IO.js (https://registry.hub.docker.com/u/errordeveloper/iojs-minimal-runtime/)The text was updated successfully, but these errors were encountered: