How does one add Swift to an existing Docker image?

I need to add Swift to an existing CentOS 7 Docker image. I'm 100% new to Docker. How can I do this?

I perused the documentation here:

However it does not give a step-by-step guide on how to add Swift to an existing Docker image. That page provides links to Apple's Swift Docker images, but it's not made clear how one would add Swift to a different Docker image than the ones shown here.

Why I need to do this:

Our existing CentOS 7 Docker image builds a server that runs on one of our CI nodes. Currently this server is responsible for building Java and TypeScript objects from protobuf objects. I need to add to this support to also build Swift protobuf objects, which we will then export to a git repo.

Things I've Already Tried that Failed

I tried copy-pasting the commands from Apple's existing CentOS 8 Swift Docker image into my image, but it fails on the last step:

Step 25/25 : RUN swift --version
 ---> Running in 75fa04b6c4cb
swift: error while loading shared libraries: cannot open shared object file: No such file or directory

I also tried adding "libtinfo" to the list of things to "yum install" however we don't seem to have it on our CentOS 7 yum repo.

I also tried simply adding this to the end of my existing docker file:

FROM swift:latest as builder
COPY . .
RUN swift build -c release

However I was unable to use "builder" since there's already a "builder" earlier in the Docker image (which is used for adding the TypeScript protobuf generator).

I changed "builder" to "builder2", but then RUN swift build -c release errors out, with "error: root manifest not found".

Any tips would be appreciated, thank you!

Combining docker images was not a straightforward task last time I tried. You could instead copy the contents of this PR

The Battle of Chosin Reservoir comes to mind. Or getting Mono to support OpenGL and sound on a 2006 PowerBook G4.

Thanks @masters3d! Problem I'm running into now is the fact that my company requires us to use certain internal yum repos for everything, and they don't seem to have half the dependencies that Swift needs.

It would be awfully nice if there was an installer for Swift that provides all the dependencies it needs to run, rather than requiring you to install all these dependency libs.

Terms of Service

Privacy Policy

Cookie Policy