Skip to content

The IMAGE_ARG_* mechanism doesn't work with multi-arch builds #110

@imsodin

Description

@imsodin

I am successfully using the multi-arch capabilities to build images for both amd64 and arm64, however not when using an image obtained through registry-image with IMAGE_ARG_* as introduced in #52 (we need it as the image is in ECR/private). It apparently uses the host arch for the base image regardless of target arch.

Small reproducer. For good measure I use oci-build-image from master tag, currently 1aac28e to get the latest buildkit updates - same result with v0.11.0:

Dockerfile:

ARG from_image=golang:1.19.5-alpine3.16
FROM ${from_image}

RUN echo test

Pipeline:

resource_types:
  - name: registry-image
    type: registry-image
    source:
      repository: "concourse/registry-image-resource"
      tag: 1.7.1

resources:
  - name: repo
    type: git
    icon: github-circle
    webhook_token: ((github_webhook.token))
    source:
      uri: https://github.com/nsat/maritime-go-bootstrap.git
      username: ((github.github_bot_username))
      password: ((github.github_bot_password))
      branch: MARITIME-1334-docker-from-image
      paths:
        - build/test
        - pipeline/task/build-docker-dualarch.yaml

  - name: from-image
    type: registry-image
    icon: docker
    source:
      repository: golang
      tag: 1.19.3-alpine3.16

jobs:
  - name: release-image
    plan:
      - in_parallel:
        - get: repo
          trigger: true
        - get: from-image
          params:
            format: oci

      - task: docker-build
        privileged: true
        config:
          platform: linux
          image_resource:
            type: registry-image
            source:
              repository: concourse/oci-build-task
              tag: master
          inputs:
            - name: repo
            - name: from-image
              optional: true
          outputs:
            - name: image
          caches:
            - path: cache
          params:
            CONTEXT: repo/build/test
            IMAGE_ARG_from_image: from-image/image.tar
            IMAGE_PLATFORM: linux/amd64,linux/arm64
            OUTPUT_OCI: true
          run:
            path: build

Relevant output:

#9 [linux/arm64 2/2] RUN echo test

#0 0.084 .buildkit_qemu_emulator: /bin/sh: Invalid ELF image for this architecture

#9 ERROR: process "/dev/.buildkit_qemu_emulator /bin/sh -c echo test" did not complete successfully: exit code: 255

------

 > [linux/arm64 2/2] RUN echo test:

#0 0.084 .buildkit_qemu_emulator: /bin/sh: Invalid ELF image for this architecture

If I remove the parts about IMAGE_ARG_*, it just works.

Tagging @vito as the author of #52 and @rdrgmnzs as the author of multi-arch support (567071e).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions