Dockerfile makes adding optional Swift dependencies easier

Most Vapor apps can run without libcurl4 and libxml2, and omitting them from your Docker image makes the run image significantly smaller (189 MB vs. 233 MB). When they are needed, Vapor's default Dockerfile now makes installing them easier.

blog.vapor.codes/posts/error-while-loading-shared-libs/

When deploying Vapor apps in Docker, omitting libcurl4 and libxml2 can reduce the image size from 233 MB to 189 MB, but apps importing FoundationNetworking or FoundationXML require these libraries, or they will crash with errors like libcurl.so.4 or libxml2.so.2 not found.

The updated Vapor Dockerfile for Ubuntu Focal highlights these optional dependencies, commenting out libcurl4 and libxml2 to encourage minimal builds. Developers should initially exclude these libraries, build and test the app, and add them only if crashes occur, verifiable using the ldd command to inspect binary dependencies. The full Dockerfile on Vapor’s repository provides the latest best practices for configuration.


Category:

Year: