VaporToOpenAPI icon indicating copy to clipboard operation
VaporToOpenAPI copied to clipboard

Building Vapor app using Docker fails on Mac when including VaporToOpenAPI

Open owainhunt opened this issue 1 year ago • 4 comments

We have a number of Vapor apps that we've started adding docs to using VaporToOpenAPI. Building in Xcode works as expected, as does building on Gitlab CI. However, when trying to build in Docker on my (M1) Mac, the build fails.

I've reproduced this on the smallest possible Vapor project (using vapor new from the command line). The docker build succeeds with the bare project, but after adding VaporToOpenAPI to the package file, the build fails at the swift build step.

Package.swift

// swift-tools-version:5.9
import PackageDescription

let package = Package(
    name: "crash-test",
    platforms: [
       .macOS(.v13)
    ],
    dependencies: [
        // 💧 A server-side Swift web framework.
        .package(url: "https://github.com/vapor/vapor.git", from: "4.89.0"),
        .package(url: "https://github.com/dankinsoid/VaporToOpenAPI.git", .upToNextMajor(from: "4.4.6"))

    ],
    targets: [
        .executableTarget(
            name: "App",
            dependencies: [
                .product(name: "Vapor", package: "vapor"),
                .product(name: "VaporToOpenAPI", package: "VaporToOpenAPI")
            ]
        ),
        .testTarget(name: "AppTests", dependencies: [
            .target(name: "App"),
            .product(name: "XCTVapor", package: "vapor"),

            // Workaround for https://github.com/apple/swift-package-manager/issues/6940
            .product(name: "Vapor", package: "vapor"),
        ])
    ]
)

Docker command: docker build -t crash-test:latest .

Dockerfile used is the standard template provided by the Vapor project

Excerpt from the build log is below:

#5 59.49 /usr/bin/clang -target aarch64-unknown-linux-gnu -g -O2 -DSWIFT_PACKAGE=1 -fblocks -fmodules -fmodule-name=CNIOBoringSSL -I /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include -fmodules-cache-path=/build/.build/aarch64-unknown-linux-gnu/release/ModuleCache -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE -fPIC -fno-omit-frame-pointer -MD -MT dependencies -MF /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_req.c.d -c /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/crypto/x509/x509_req.c -o /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_req.c.o
#5 59.58 /usr/bin/clang -target aarch64-unknown-linux-gnu -g -O2 -DSWIFT_PACKAGE=1 -fblocks -fmodules -fmodule-name=CNIOBoringSSL -I /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include -fmodules-cache-path=/build/.build/aarch64-unknown-linux-gnu/release/ModuleCache -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE -fPIC -fno-omit-frame-pointer -MD -MT dependencies -MF /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_obj.c.d -c /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/crypto/x509/x509_obj.c -o /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_obj.c.o
#5 59.67 /usr/bin/clang -target aarch64-unknown-linux-gnu -g -O2 -DSWIFT_PACKAGE=1 -fblocks -fmodules -fmodule-name=CNIOBoringSSL -I /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include -fmodules-cache-path=/build/.build/aarch64-unknown-linux-gnu/release/ModuleCache -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE -fPIC -fno-omit-frame-pointer -MD -MT dependencies -MF /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_lu.c.d -c /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/crypto/x509/x509_lu.c -o /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_lu.c.o
#5 59.81 /usr/bin/clang -target aarch64-unknown-linux-gnu -g -O2 -DSWIFT_PACKAGE=1 -fblocks -fmodules -fmodule-name=CNIOBoringSSL -I /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/include -fmodules-cache-path=/build/.build/aarch64-unknown-linux-gnu/release/ModuleCache -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L -D_DARWIN_C_SOURCE -fPIC -fno-omit-frame-pointer -MD -MT dependencies -MF /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_ext.c.d -c /build/.build/checkouts/swift-nio-ssl/Sources/CNIOBoringSSL/crypto/x509/x509_ext.c -o /build/.build/aarch64-unknown-linux-gnu/release/CNIOBoringSSL.build/crypto/x509/x509_ext.c.o
#5 60.98 error: compile command failed due to signal 9 (use -v to see invocation)
------
process "/bin/sh -c swift build -c release                 --static-swift-stdlib                 -Xlinker -ljemalloc -v" did not complete successfully: exit code: 1

owainhunt avatar Feb 16 '24 16:02 owainhunt

I'm having the same issue, has there been any progress on this?

alexandrehsaad avatar Mar 02 '24 14:03 alexandrehsaad

@dankinsoid any update on this please? 🙏

owainhunt avatar Apr 05 '24 13:04 owainhunt

hi, I'll try check

dankinsoid avatar Apr 05 '24 22:04 dankinsoid

@owainhunt Unfortunately I didn't reproduce the bug on my M2 machine, maybe it's possible with M1 only, but I don't have a M1 device

dankinsoid avatar Apr 06 '24 05:04 dankinsoid