Additional Linux Distributions

Hello,

Happy to share a new set of Linux distributions officially supported by the Swift project.

Swift.org now offers downloadable toolchain and Docker images for the following Linux distributions:

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04 (new)
  • CentOS 8 (new)
  • Amazon Linux 2 (new)

Full details in: https://swift.org/blog/additional-linux-distros/

We would love to work together to add additional distributions. Natural candidates are CentOS 7, Debian 9, and Fedora 32.

We use Docker based virtual build environment to build & qualify Swift on Linux (e.g. https://github.com/apple/swift-docker/blob/master/swift-ci/master/centos/8/Dockerfile), which is designed to support additional distributions. Once a working Dockerfile is added to this repository, we can set up CI jobs to produce official toolchains.

40 Likes

Will there be a 5.2.x release for these platforms?

4 Likes

Well done, and welcome Ubuntu latest LTS and Amazon Linux 2 join the swift family.

2 Likes

This is amazing! Are there any plans to support Alpine? I had some attempts to make it build on Alpine, but that seemed like a project big enough on its own. Is supporting Alpine even on the roadmap? This would greatly help in reducing sizes of Docker images for certain tasks.

1 Like

In a similar discussion here there was a post that somebody succeeded using SCRATCH instead of Alpine: Vapor 4 deployment on small docker image like for instance 12.1-alpine . I don't know if that would be sufficient for you.

Another discussion on that topic from a year ago can be found here: Idea: runtime/slim images

regards,

Lars

1 Like

This is great news for the language. Personally I'm looking forward to seeing how small a deployable Docker image can get with these new distros in play. Has anyone done a roundup of base image sizes, or base image sizes + Swift runtime dependencies?

The CentOS and Amazon Linux docker image are missing the git command and zlib. Is it normal?

Hi Susan,

git is not a dependency of Swift, so if it is not installed on the distro by default, it won't be included in the Swift images. As for zlib, I just checked both and they come with zlib pre-installed. Is there any specific issue you have observed with the images?

Hi Max,

we will be focussing on the distros that @tomerd outlined in his post next, but if you are interested in adding Alpine Linux support, contributions to the docker files are always welcome.

1 Like

Isn’t it a dependency of the Swift Package Manager?

It seems like the installation instructions on Linux have changed with the addition of these distributions. For Ubuntu 18.04, the instructions mention the following dependencies:

libatomic1
libcurl4
libxml2
libedit2
libsqlite3-0
libc6-dev
binutils
libgcc-5-dev
libstdc++-5-dev
zlib1g-dev
libpython2.7
tzdata
pkg-config
curl

This used to be only clang and libicu-dev (and git for SwiftPM). Are these really all required for running Swift (not building it from source)? Or did you replace clang by its dependencies?

I'd like to narrow down this list, if possible, in the instructions I give to my students. Installing Swift is already pretty cumbersome. I'm hoping it will eventually just be apt install swift-lang.

2 Likes

Ah, you're right. We'll fix that. Thanks!

Thanks!

Note that swift.org publishes two versions of docker file, one is the normal image (e.g. swift:5.2) which has all the dependencies required to build programs with Swift, the other is the "slim" image (e.g. swift:5.2-slim) which only has the dependencies required to run programs compiled for that platform. The slim images are much smaller.

Of course, there is work that can be done to bring Swift to smaller distros, and we would love to see the community help with that

@svanimpe this is indeed our goal. On another note, have you considered using Docker with your students?

I'm targeting first-year students with no prior programming or CS experience, so Docker isn't an option here.

Thanks to @Ron_Olson's hard work, on Fedora, you can just dnf install swift-lang.

1 Like

A word of caution for folks who want to build these images using Podman. I discovered an issue with how Podman/Buildah is handling the use of ARG and ENV in the Dockerfile. I've opened an issue here.
The workaround is to add an additional ARG line before the ENV one:

ARG SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER"

This is not an issue with regular Docker, but Fedora is big on Podman as a Docker replacement, so :man_shrugging:.

+1

If there are folks here that are interested and can help get formal deb packages, rpms, etc into the main repositories we would love to work with you to get that done

7 Likes

Yes, but the header file is missing. The Ubuntu version comes with the zlib1g-dev installed.

Terms of Service

Privacy Policy

Cookie Policy