Create a repo swift-docker-base for swift track

As I knew, one of the problems with the current swift-test-runner is its large docker image size (~1 GB). There have been some attempts to address this issue.

As a proof of concept, I tried to reduce the size and achieved about a 40% reduction to 630 MB by removing libs and binaries that don’t seem necessary for Exercism’s needs.

The idea is simple: take the original swift Dockerfile and edit it to keep number of docker layers small as possible.

    && tar -xzf swift.tar.gz --directory / --strip-components=1 \
    && rm \
        /usr/lib/liblldb.so* \
        /usr/lib/libsourcekitdInProc.so \
        /usr/lib/libswiftDemangle.so \
        /usr/lib/libSwiftSourceKitClientPlugin.so \
        /usr/lib/libSwiftSourceKitPlugin.so \
        /usr/bin/docc \
        /usr/bin/lld \
        /usr/bin/lldb \
        /usr/bin/lldb-argdumper \
        /usr/bin/lldb-dap \
        /usr/bin/lldb-server \
        /usr/bin/sourcekit-lsp \
        /usr/bin/swift-format \
        /usr/bin/swift-plugin-server \
        /usr/bin/wasmkit \
    && rm -r \
        /usr/lib/swift_static \
        /usr/lib/swift/embedded \

Removing all of this still allowed me to build and test a single package, although I haven’t tested it across the full spectrum of exercises.

Could this be considered a significant improvement? Who would be interested in helping to create a repository for it like nim-docker-base?

2 Likes

@Meatball I’m really sorry to bother you again, but I honestly don’t know who else I could ask for advice.

Sorry been quite busy, so havn’t had the time to look at the forum (so pinging me is often a good solution). But yes I think this could be relevant to have a docker-image-base. @iHiD, could you take a look at this.

@ErikSchierboom may also be able to help

GitHub - exercism/swift-docker-base has been created. The Swift team has write permissions

3 Likes

Thanks a lot, will create a PR in a couple of days with suggested changes.

PR is created. Final size is ~413 MB

2 Likes

@ErikSchierboom, Could you please add the required secret keys and bots to the GitHub repository when you have a moment?

Done! Secrets added.

Thank you! Could you please also rerun failed deploy and sync labels CI jobs? They should be available to be triggered from web interface.

The sync labels script fails due to:

unable to load manifest: open .github/labels.yml: no such file or directory

I think the best way to fix this is to copy this file from another repo.

I’ve fixed the deploy workflow.

1 Like

This two PR’s need attention:

Please review and merge.