I used to do various Raspberry Pi Docker images over here https://hub.docker.com/repository/docker/helje5, e.g. https://hub.docker.com/repository/docker/helje5/arm64v8-swift-dev. Based on various methods provided by the community (e.g. some on Future Jones stuff', some based on packages provided by Uraimo, etc.). They are not very up2date anymore but maybe useful to someone ;-)
I'm no expert on this, but I think an issue is ARM compatibility. To be honest I was surprised that M1's can even run ARM Linux out of the box. The problem is that ARM is not ARM, the vendors can add/remove features at will.
E.g. 2 years ago or so I tried to build Swift on the ARM instances provided by Scaleway. That didn't work out, because their boards had a different feature set (different Neon version? Something like that).
In other words, the question is what the Swift provided image would be. Is it an M1 optimised one which only works in M1 Docker? One which also works on Raspi's? Or on other boards? Which one?
(but again: I'm no expert on ARM, maybe that's a non-issue today, e.g. Graviton also seems to work out of the box?).
Just tried it, and this just works:
helge@M1ni ~ $ docker run helje5/arm64v8-swift-dev:5.0-latest swift --version
Swift version 5.0 (swift-5.0-RELEASE)
This is the GitHub repo used for building the images: https://github.com/helje5/dockSwiftOnARM.
And another update: I've pushed 5.3.2 images based on FutureJones' build. This allows me to build Macro.swift directly in Docker on the M1:
helge@M1ni MacroExpress $ docker run --rm -v "$HOME/dev/Swift/Macro/MacroExpress:/src" -v "$HOME/dev/Swift/Macro/MacroExpress/.docker.build:/src/.build" helje5/arm64v8-swift-dev:5.3.2 bash -c 'cd /src && swift build -c release'
Resolving https://github.com/apple/swift-log.git at 1.4.0
Resolving https://github.com/AlwaysRightInstitute/mustache.git at 0.5.9
Resolving https://github.com/Macro-swift/Macro.git at 0.6.2
Resolving https://github.com/apple/swift-nio.git at 2.25.1
[1/12] Compiling mime MIME.swift
[2/12] Compiling CNIOWindows shim.c
[3/12] Compiling CNIOWindows WSAStartup.c
[4/12] Compiling CNIOSHA1 c_nio_sha1.c
[5/12] Compiling CNIOLinux shim.c
[6/12] Compiling xsys Module.swift
[7/12] Compiling Logging Locks.swift
[8/12] Compiling CNIODarwin shim.c
[9/12] Compiling CNIOHTTPParser c_nio_http_parser.c
[10/12] Compiling mustache HTMLEscape.swift
[11/12] Compiling c-nioatomics.c
[12/12] Compiling c-atomics.c
[13/13] Compiling NIOConcurrencyHelpers NIOAtomic.swift
[14/14] Compiling NIO AddressedEnvelope.swift
[15/16] Compiling NIOFoundationCompat ByteBuffer-foundation.swift
[16/17] Compiling MacroCore Buffer.swift
[17/18] Compiling NIOHTTP1 ByteCollectionUtils.swift
[18/19] Compiling fs Directory.swift
[19/20] Compiling dotenv dotenv.swift
[20/20] Compiling http Agent.swift
[21/21] Compiling connect BodyParser.swift
[22/22] Compiling express BasicAuth.swift
[23/23] Compiling MacroExpress MacroExpress.swift
helge@M1ni MacroExpress $ du -sh .docker.build/aarch64-unknown-linux-gnu/release/