Idea: runtime/slim images

Yes, I wasn't saying it was impossible, just that it's not entirely within our gift.

I would really like to see

  • swift:5.0-slim (base on Ubuntu)
  • swift:5.0-alpine
  • swift:5.0-alpine-slim

:grin:

3 Likes

Wow I'm coming late to this thread. @IanPartridge this is fantastic! I've been wanting this and I know others have been asking me this for a while now! :heart:

1 Like

I've got a PR up with prototype slim Dockerfiles for Swift 5.0.1. Please take a look and try them out!

8 Likes

The slim images are working for us (Kitura) in our testing, so I've merged them to master. They are not available on Docker Hub yet as I suggest we make them generally available alongside the next Swift release.

Please do try them out and post your experience. I'm particularly interested to check they work for Vapor.

2 Likes

Super awesome @IanPartridge! I'll give them a spin for sure. Out of curiosity, do you already have size comparison between the normal & slim images? :smile:

1 Like

Full bionic (18.04): 1.35GB
Slim bionic (18.04): 226MB :tada:

Full xenial (16.04): 1.37GB
Slim xenial (16.04): 249MB :tada:

18 Likes

Woah! I expected improvements, but that's just mindblowing! Very nice work on this!

1 Like

Very nice job, but I think it can be smaller. I tried to compile Swift on Alpine, but got many errors and stop doing this, but I think Alpine would be the smallest base image for "cloud-native" Swift. :smirk:

We implemented something similar to this: A Minimal Swift Docker Image. Off and on for over a year, I’ve been… | by Jeremy Jacobson | Medium, in which we basically start from a slimed down version of Ubuntu (abt 50MB) and add just the libraries the compiled Swift program links to. We are able to get images in the range of 150MB including our own code (NIO based server stuff).

Earlier, we had issues with Alpine Linux not being able to resolve hostname to ip from inside the container (see https://github.com/gliderlabs/docker-alpine/issues/8 which was not really resolved as of late last year). We haven't tried Alpine since.

cc: @ilyaK

1 Like