Open pini-gh opened 1 year ago
As a workaround, tweaking the Dockerfile to pull the foreign arch first does work:
FROM debian:bullseye-slim as target
FROM --platform=$BUILDPLATFORM debian:bullseye-slim as build
# Do cross compilation
FROM target
# Do installation
Then I guess that the issue is that --platform
information is lost after the first stage.
Hi @pini-gh , The issue happens because buildah's cache mechanism only considers history not the original architecture requested, I guess this can be fixed at buildah end, thanks for creating the issue and reporting :) I'll check this.
A friendly reminder that this issue had no activity for 30 days.
@flouthoc any update?
A friendly reminder that this issue had no activity for 30 days.
Description
I've successfully set up a gitlab runner after this documentation.
It works great for single-stage Dockerfile, but when building multistage for a foreign architecture it pulls the wrong arch image at the final stage.
Note: single stage builds are OK.
Steps to reproduce the issue:
My box runs Debian testing amd64. The current podman version is 4.3.1. The package
qemu-user-static
is installed.Set up a new
buildah-issue
directory with this Dockerfile:FROM --platform=$BUILDPLATFORM debian:bullseye-slim as build ARG BUILDPLATFORM ARG TARGETPLATFORM
RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y install jq dpkg-dev RUN mkdir -p /build && cp /usr/bin/jq /build/ RUN dpkg-architecture
=========================================
FROM debian:bullseye-slim
RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y install dpkg-dev file RUN dpkg-architecture
COPY --from=build /build /usr/local/bin/ RUN file /usr/local/bin/jq /bin/bash
This tow stages Dockerfile is written after this Docker documentation:
Run
quay.io/buildah/stable
with this folder mounted$ podman run --privileged --rm -it -v ./buildah-issue:/buildah-issue quay.io/buildah/stable
Enter the mounted volume and build with
--layers --platform linux/amd64
cd /buildah-issue
buildah bud --layers --platform linux/amd64 --tag test:amd64-latest -f Dockerfile .
Do the same with
--layers --platform linux/arm64
buildah bud --layers --platform linux/arm64 --tag test:arm64-latest -f Dockerfile .
Describe the results you received:
When building for
linux/arm64
at the second stage every layer is pulled from the cache after thelinux/amd64
build, and the resulting image is the very same as thelinux/amd64
one:Describe the results you expected:
The second stage base image should have pulled the
linux/arm64
debian:bullseye-slim
image from docker.io registry instead of pulling thelinux/amd64
one from the cache.Output of
buildah version
:As said above I use buildah from image
quay.io/buildah/stable
. In this context:Output of
podman version
on the host*Output of `cat /etc/release`:**
Output of
uname -a
:Output of
cat /etc/containers/storage.conf
:No such file. I don't think this is relevant in this context anyway.