Skip to content

Draft: Rearchitecture Dockerfile to create smaller image

The current Docker image for Snowflake proxy is gigantic at 319.83 MB compressed and 905 MB on disk. As most of this is space usage are Golang package (installing golang-go on Debian itself takes nearly 700 MB on disk) and build dependencies, I think we need to do different approach at making this image. It also helps that binaries compiled by Go on default settings don't need any runtime dependencies, so we can just strip everything down.

So I rearchitectured the Dockerfile to do an entirely different way of building the image: instead of using golang as base image, I started with the lightweight Alpine Linux. Then I installed golang and every other build dependencies, then download Snowflake's tarball, extract and compile it and put it in /usr/local/bin. Finally, I just removed the tarball, extracted tarball and every build dependencies.

This resulted in a massively smaller image at only 13 MB compressed and about 30 MB on disk. You can check out my Docker Hub to see my build results.

I also removed the hardcoded addresses from ENTRYPOINT so proxy operators can provide the settings themselves by adding a command: line in docker-compose.yml or when running docker run or just use the default settings. So this will also close #1 (closed)

If using Alpine Linux is not something we are fond of, I also created a similar one but using Debian as the base image. But Debian creates a significantly larger image at about 50 MB compressed and about 130 MB on disk.

Edited by Ridhwan Ikhwanto

Merge request reports