Chapter 11 Apple silicon Fix

I was having a difficult time getting the chapter 11 linux testing to run on Apple silicon. It took awhile to get to the actual fix, but it just requires a quick change to the provided code in the chapter.

The provided code for testing.Dockerfile is as such

# 1
FROM swift:5.2

# 2
WORKDIR /package
# 3
COPY . ./
# 4
CMD ["swift", "test", "--enable-test-discovery"]

this will give the following errors:

ERROR [internal] load metadata for docker.io/library/swift:5.2 
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest

The fix is to just match FROM swift version from the normal `DockerFile

# 1
FROM swift:5.6-focal as build

# 2
WORKDIR /package
# 3
COPY . ./
# 4
CMD ["swift", "test", "--enable-test-discovery"]

Everything now works as expected.

1 Like