Kickstarting new official Docker support for Swift

Greetings fellow Swifters,

Currently there is an unofficial Docker image for Swift supported by the SwiftDocker (docker-swift) project. The Core Team would like to integrate support for an official Docker image directly into the Swift project to create concentrated and official support for Docker images that the Swift community can rely upon. Thomas Catterall and I have volunteered to help coordinate this effort with broader Swift community.

The specific goals going forward are:

  • Transfer Docker’s recognition of the official Swift docker image to come from the Swift.org project instead of docker-swift.

  • Create Docker images that support the Linux distributions officially supported by Swift, as well as expand that set of supported distributions over time.

  • Provide more variants of Docker images to support different user and developer workflows.

The following is a tentative phase plan for this effort:

  • Phase 1: Host the Dockerfiles for the "official" images in the Apple organization

  • Phase 2: Add support in the Swift CI for regularly building and testing the Docker images. This enables us to do continuous testing that the images are valid.

  • Phase 3: Expand support to all supported distributions and versions. This ensures that we have support for Ubuntu 14.04, 16.04 and 18.04 when support arrives.

  • Phase 4: Verify contents of Docker image ensuring that the contents of the build image meets the majority of server use cases such as SwiftNIO, Kitura, Vapor and Perfect applications building out-of-the-box.

  • Phase 5: Provide support for separate Build/Debug and "Slim" Runtime images. The "Slim" image would contain the minimum required to run (but not build) and application. A multi-stage Dockerfile can then we used to build inside the Build/Debug image and copy into the "Slim" runtime image

  • Phase 6: Add support for multi-arch Docker images As additional architectures are officially supported through the community Swift CI, we can look at moving to multi-arch Docker images that add in support for those platforms.

To support this effort, a new “Docker” category to the forums will be added under “Development > Server” as well as a new category in JIRA.

Thomas, myself, and the Core Team would like to also thank everyone who contributed to docker-swift, and we welcome the entire community to participate in the development of these new images.

We're excited to see how the new, official Docker images will benefit Swift on Server!

We are very excited about this effort and hopefully so are you!

Haris

48 Likes

I think the tentative plan is great, especially this part. Running in a container that doesn't need the compiler is a huge space saver. :+1:

As soon as these images are publicly available, I will move Vapor's development workflow to using them.

One question: Will this include development / nightly toolchains as well?

4 Likes

Running in a container that doesn't need the compiler is a huge space saver.

Even more important, it is a huge security saver.

6 Likes

IBM claims to have very good and platform agnostic images. Did you ever talk to them? /cc @IanPartridge

1 Like

@Helge_Hess1 yup we have been talking w/ @IanPartridge :slight_smile:

1 Like

@tanner0101 we're not sure about that at the moment, but of course community input on this would be highly appreciated. We'll definitely know more as Swift CI integration rolls along.

Btw, there's a new forum category for discussion of the docker images. Check it out:
https://forums.swift.org/c/development/docker

4 Likes

Being able to test Vapor (including HTTP, DB drivers, ORM, etc) on the latest dev toolchains / betas is really helpful for us (and the Swift core team) to catch bugs early. :raised_hands:

6 Likes

Would phase 6 include Raspberry Pi support officially? These is hit or miss support for RPI support with Swift as it it due to some URLSession and Package Manager bugs so it would be nice to have this as a low cost alternative. Hypriot is the easiest way to run Docker on a Pi and this swift image docker container is available from 3rd party devs Docker Hub. It would be nice to see some official support for this.

1 Like

RasPi (both rpi and arm64v8) is a little different because the Swift project doesn't provide the binary drops for those. (I guess) the proper way to do them is to first provide official tarballs, and then build images on top of them.

My RPi images you are referring to used to build Swift straight from source (applying the necessary patches), but the recent ones are just pulling in community provided drops.

(another difficult thing in the ARM world is that RasPis are just one popular board, there are many more (e.g. those deployed by Scaleway, etc etc), and the ARM CPUs are highly customisable (i.e. have different features even when they share the basic architecture)

2 Likes

Our images have worked well for us so far, but we're excited to see Swift get its own official Docker images. We plan to support this new effort :slight_smile:

11 Likes

This is great news! Thanks for the effort. :slight_smile:

1 Like

Is anyone working on Vapor using Alpine or Busybox docker container images? Larger corporations cant leverage Ubuntu due to it's massive footprint... btw there is no apt-get in either of these tiny footprint distros

3 Likes

Swift in busy box linux would potentially open the door for (re)writing dd/open-wrt in swift. Using Vapor as the web backend and interfacing with C libraries through swift for the networking stuff. Not saying that's a good idea or that it would ever actually happen, but it'd be possible. :joy:

3 Likes

Last I heard, Swift on Alpine has some serious technical obstacles in the way as the glibc dependency is quite hard.

More feasible might be to target a Debian slim base image (55MB) instead of Ubuntu Xenial (115MB)?

6 Likes

While we wait on the official images, I've set up a very rudimentary Swift 5.0 on Ubuntu 18.04 Dockerfile to use. This is just for testing obviously, but I thought I would share.

https://hub.docker.com/r/codevapor/swift/tags/

codevapor/swift:5.0

8 Likes

Update: This docker image is now named vapor/swift:5.0.

2 Likes