I'm using Swift Package Manager to build my Swift server app in a Linux Docker container. Each time I rebuild it fetches all of the dependencies and rebuilds them all. Recently I started using Swift-NIO as a dependency and it takes a while to compile. Are incremental builds supported on Linux?
I tried to get incremental builds working by having my Package.swift + some dummy files copied into docker -> build -> copy in the real source files -> build. I was hoping the dependencies of the first build would be saved for the second build. Unfortunately, even if I just do two identical build commands one after another it still rebuilds all dependencies from scratch. Are incremental builds on Linux supported?
This is the docker file I'm using:
FROM bridger/swift-ubuntu:latest MAINTAINER Bridger LABEL Description="Docker image for building and running the Scribble server." EXPOSE 9080 RUN mkdir /root/Scribble-Server ADD Tests /root/Scribble-Server/Tests ADD Package.swift /root/Scribble-Server ADD Package.resolved /root/Scribble-Server # Add a dummy file for resolving dependencies and pre-building first ADD Sources/DummyForDependencies/main.swift /root/Scribble-Server/Sources/ScribbleServer/main.swift ADD Sources/DummyForDependencies/DummyModel.swift /root/Scribble-Server/Sources/CanvasModel/DummyModel.swift # Resolve the dependencies by building using the dummy sources RUN cd /root/Scribble-Server && export KITURA_NIO=1 && swift build -c release # Delete the dummy sources RUN rm /root/Scribble-Server/Sources/ScribbleServer/main.swift RUN rm /root/Scribble-Server/Sources/CanvasModel/DummyModel.swift # Add in the real sources ADD Sources /root/Scribble-Server/Sources RUN rm -rf /root/Scribble-Server/Sources/DummyForDependencies # Build again. This unfortunately rebuilds all dependencies, even though they haven't changed RUN cd /root/Scribble-Server && export KITURA_NIO=1 && swift build -c release