Hello, I have a question related to building containers for multi architectures.
I am working from a mac the the M1 arm chip.
Usually, I write my docker file and use the command
docker buildx build --platform linux/arm64,linux/amd64 -t name:latest --push .
And this works fine, as the commands in the dockerfile are the same for both architectures.
However, I now have a case where the commands are different for arm64 and amd64.
For example, for arm64 I need to write:
RUN cd ~/github && \
git clone https://github.com/lh3/minimap2.git && \
cd minimap2 && \
make arm_neon=1 aarch64=1
While for amd64 I need to write:
RUN cd ~/github && \
git clone https://github.com/lh3/minimap2.git && \
cd minimap2 && \
make
I wrote this docker file:
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive
# Add build arguments for specific architectures
ARG TARGETPLATFORM
RUN mkdir ~/github
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
cd ~/github && \
git clone https://github.com/lh3/minimap2.git && \
cd minimap2 && \
make arm_neon=1 aarch64=1; \
elif ["$TARGETPLATFORM" = "linux/amd64"]; then \
cd ~/github && \
git clone https://github.com/lh3/minimap2.git && \
cd minimap2 && \
make; \
fi
ENV PATH="$PATH:/root/github/minimap2/"
And I am using this command to build the image:
docker buildx build --platform linux/arm64,linux/amd64 -t name:latest --push .
However, the program minimap
is installed only on the image for arm64 arch, while the image for amd64 gets built but does not have minimap.
Is there a way to have a single dockerfile with these two commands and specify that each is for a different architecture, and then run a single docker buildx
command?
Thanks
Marco