Among others, Poetry depends on pyrsistent, msgpack, and cryptography packages, and these don’t have wheels for arm64 -- so they need a compile step themselves -- but python:3.8-slim doesn’t include gcc.
My first attempt was to change the first-stage to RUN apt update && install -y –no-install-recommends build-essential libssl-dev libffi-dev python3-dev && pip3 install poetry && apt remove –y –purge build-essential libssl-dev libffi-dev python3-dev. I verified that this allowed Poetry itself to be built.
NOTE: for some reason apt install python3-dev selected python3.7-dev from the archives, although the base image is called python:3.8.
Invoking Poetry would then also need GCC for some other package, and at that point I figured a smaller and more maintainable change would be to use the non-slim image for the initial stage; this appears to include the libffi and openssl headers, along with GCC and whatever's needed to compile a wheel in arm64.
I reckon the disk space from apt install build-essential is in the ballpark of using the full python:3.8 image anyway, and doing this saves having to debug why apt install was selecting 3.7-dev and didn't have 3.8.
I don't understand what you mean by "final build look like", but I had errors in two of the stages:
pip3 install poetry
the poetry invocation
For the first one I was able to just install enough compiler as you see above. From my notes, pyrsistent, msgpack, and cryptography needed a build because they didn't have wheels available.
And then I facepalmed when apt install && pip3 install poetry && apt remove worked, but poetry install also started trying to compile stuff. That's the point at which I tried the non-slim base for the first step of the Dockerfile. It worked directly, first try.
So, this is a yes for your second question. An alternative method would be to have the upstream wheels also be available in arm64 releases.
As for the first question: most of the pip3 install poetry step is just downloading wheels except for those 3 packages. The poetry.lock has a bunch of wheels that are only i686 or x86_64, so I'll assume all those need a compile. Sorry I didn't keep better notes for the second step.
Did I answer both your questions?
Hey, did I end up answering your question, or should I reword? :)