openfaas / faas-swarm

OpenFaaS provider for Docker Swarm
https://github.com/openfaas/faas
MIT License
79 stars 38 forks source link

Using Alpine in Multistage Build to Reduce Junk #37

Closed auyer closed 5 years ago

auyer commented 5 years ago

Expected Behaviour

Multistage builds should leave as little junk as possible. Golang alpine 1.11 image fails on cgo dependent tasks.

Current Behaviour

Multistage Docker builds leave the "build" parts in disk as untagged images, ans and using the Fat Golang image in this step produces more than 500Mb.

Possible Solution

Use alpine images. To use the 11.1 Go Alpine image, it is necessary to add gcc and libc-dev apks to the Dockerfile.

Steps to Reproduce (for bugs)

  1. build the Docker Swarm image
  2. check the leftovers

Context

This issue prevent unecessary disk and network usage when deploying on Docker Swarm.

Your Environment

auyer commented 5 years ago

Are there other resons why it should be kept at the default golang image, and at the 1.10.4 golang version ?

The fixes I proposed ( gcc and libc-dev ) seem to have solved all cgo problems.

alexellis commented 5 years ago

We won't be moving to Golang 1.11 at this stage, please see the tracking issue - I've explained this several times. https://github.com/openfaas/faas/issues/875

I'd also prefer to use the default Golang image over Alpine for consistency. There may be other implications about compiling against musl-dev that are not obvious.

alexellis commented 5 years ago

Derek lock: invalid - see tracking issue.