During the weekend, I made an attempt to rewrite my Vapor-based service written in Swift to Python using FastAPI. It did not go well... I had a feeling of something uncomfortable and out of my control.
And, before going too deep and reimplementing, I decided to check what the size of the container is. The average is 350-450 MB. There is no point. Also consuming a lot more RAM.
I'm back to Swift+Vapor. I managed to reduce the size of the image to about 300MB and reduce the build time to 20 minutes, splitting it into to runs ARM64 and AMD64.
@sakrist Hmmm. Why is it 300MB? Are you including the entire Swift runtime?

@pixelscience I have not looked at binary yet, don't know why it is so big. This is next once I have it at least running in some what automation on my k cluster.

But in short, you can try guess by this example https://github.com/vapor/template-fluent-postgres/blob/main/Dockerfile

another reason could be because of this package
https://github.com/dankinsoid/VaporToOpenAPI

template-fluent-postgres/Dockerfile at main · vapor/template-fluent-postgres

A template ready for use configured with Fluent and PostgreSQL - vapor/template-fluent-postgres

GitHub

@sakrist According to Dockerfile:30 it builds with static linking. (Yay!) https://github.com/vapor/template-fluent-postgres/blob/dd97098a73fb8a93d0f3a35a281f78aa574d95df/Dockerfile#L30

Bad news is that 300MB still feels really large.

template-fluent-postgres/Dockerfile at dd97098a73fb8a93d0f3a35a281f78aa574d95df · vapor/template-fluent-postgres

A template ready for use configured with Fluent and PostgreSQL - vapor/template-fluent-postgres

GitHub