Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-platform build failing due to outdated skopeo in ubuntu-latest #191

Open
aaronadamsCA opened this issue Jan 5, 2023 · 21 comments
Open
Assignees
Labels
bug Something isn't working upstream

Comments

@aaronadamsCA
Copy link

A basic multi-platform build workflow currently fails:

workflow.yml

on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: docker/setup-qemu-action@v2
        with:
          platforms: arm64
      - uses: docker/setup-buildx-action@v2
      - uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ github.token }}
      - uses: devcontainers/ci@v0.2
        with:
          imageName: ghcr.io/${{ github.repository }}/devcontainer
          platform: linux/amd64,linux/arm64

The error:

  Error: Dev container build failed: Command failed: docker tag vsc-repository-d8fa4a8f8a3fefdc0feb211b3b07a31c-features ghcr.io/organization/repository/devcontainer:latest (exit code: undefined)
  An error occurred building the container.
  Error: Command failed: docker tag vsc-repository-d8fa4a8f8a3fefdc0feb211b3b07a31c-features ghcr.io/organization/repository/devcontainer:latest

Single-platform builds are working fine.

I don't think this is relevant, but just in case:

.devcontainer/devcontainer.json

{
  "image": "mcr.microsoft.com/devcontainers/base:jammy",
  "features": {
    "ghcr.io/devcontainers/features/node:1": {}
  },
  "updateContentCommand": ".devcontainer/install.sh"
}
@natescherer
Copy link
Contributor

Hi @aaronadamsCA, I suspect that this might be an incompatability between a new version of Docker BuildX and the older version of Skopeo available on the action runner images. Can you try adding this before the build step and see if it works?

      - name: Install updated Skopeo
        # This can be omitted once runner images have a version of Skopeo > 1.4.1
        # See https://github.com/containers/skopeo/issues/1874
        run: |
          sudo apt purge buildah golang-github-containers-common podman skopeo
          sudo apt autoremove --purge
          REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable"
          source /etc/os-release
          sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list"
          sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key
          sudo apt-key add Release.key
          sudo apt-get update
          sudo apt-get install skopeo

@aaronadamsCA
Copy link
Author

@natescherer I tried this just now, but the result is the same.

@eitsupi
Copy link

eitsupi commented Feb 12, 2023

Could it have something to do with not setting up the push option?
We can't keep multi-platform built images locally (on Docker), can we?

@baldwicc
Copy link

FWIW, I'm getting the same docker tag failure with the Azure DevOps task example

@metaskills
Copy link

metaskills commented Mar 16, 2023

I just got to this issue from a diff skopeo error.

2023-03-16T19:03:47.1593665Z Copying blob sha256:0634d0a905f9779487b6a35339b867602878bcfe541ac60331bb706c1b12540c
2023-03-16T19:03:48.6288258Z time="2023-03-16T19:03:48Z" level=fatal msg="creating an updated image manifest: preparing updated manifest, layer \"sha256:b0d6db02944d51231a28352b5c6372611214ea1a5e886d49625724204dc5c0eb\": unsupported MIME type for compression: application/vnd.in-toto+json"
2023-03-16T19:03:48.6383712Z ##[error]Error: skopeo copy failed with 1

My configs are pretty simple.

- name: Build & Push Container
  uses: devcontainers/ci@v0.3
  with:
    push: always
    imageName: ghcr.io/customink/some-devcontainer-service
    cacheFrom: ghcr.io/customink/some-devcontainer-service
    subFolder: .devcontainer/service
    platform: linux/amd64,linux/arm64

I can build a single platform (any of the two) but not both.

@metaskills
Copy link

@natescherer Were you hinting at this issue? containers/skopeo#1874 I found it when I googled my error. I found that ubuntu-latest has version 1.4.1. I applied your update and my issue disappeared.

@metaskills
Copy link

Correction, the skopeo update did not work after I deleted my container package. Think it only worked because of some caching. Once I deleted my package and tried again with the devcontainers/ci workflow snippet above, things broke again and nothing helped.

@stuartleeks
Copy link
Collaborator

@metaskills - the config we use for the GitHub tests is here, including the skopeo install steps.

@baldwicc - the corresponding Azure DevOps test is here

@zydou
Copy link

zydou commented Mar 17, 2023

I have also encountered this docker tag error despite having updated the skopeo package. After several attempts, I found that this issue arises only if your devcontainer.json is image based in conjunction with devcontainer-features.

For example, the following devcontainer.json will fail with the docker tag error:

{
  "image": "mcr.microsoft.com/devcontainers/base:jammy",
  "features": {
    "ghcr.io/devcontainers/features/node:1": {}
  }
}

A temporary workaround is to change your devcontainer.json to Dockerfile based. To fix the error:

  1. Change your devcontainer.json to Dockerfile based.
{
  "build": {
    "dockerfile": "./Dockerfile",
    "context": "."
  },
  "features": {
    "ghcr.io/devcontainers/features/node:1": {}
  }
}
  1. Create a Dockerfile file in the same dir with the devcontainer.json file
FROM mcr.microsoft.com/devcontainers/base:jammy

@stuartleeks
Copy link
Collaborator

Interesting. Thanks for the investigation @zydou !

Until this is fixed, there's a helpful extension that @bamurtaugh created for converting image-based dev containers to Dockerfile: https://marketplace.visualstudio.com/items?itemName=Brigit.devcontainer-image-convert

@aaronadamsCA
Copy link
Author

I am happy to confirm that @zydou's finding is an effective workaround for me as well.

@aaronadamsCA
Copy link
Author

Actually, it turns out @natescherer's Skopeo workaround was necessary as well.

It looks like we actually have two different issues being tracked here, then:

@stuartleeks
Copy link
Collaborator

The failure with image based dev containers needs more investigation to determine the underlying cause.

For the skopeo copy issue, there are a couple of things that we could do:

  1. Check the skopeo version and output a message if it is outdated (and point to the docs)
  2. Consider adding a skipAttestation option (this would need to be added to the CLI first)

@aaronadamsCA
Copy link
Author

Also worth noting I tried to work around this by setting build.args to { "--sbom": "false", "--provenance": "false" }, but then the post-action skopeo copy command failed with fatal error unsupported MIME type for compression.

So it looks like the only real solution is the Skopeo update, which we're now doing without issue.

@stuartleeks
Copy link
Collaborator

@aaronadamsCA - thanks for the follow-up message

@m-roberts
Copy link

I was able to update the version of Skopeo on an Ubuntu 22.04 GitHub Actions runner with the following:

REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04"
sudo sh -c "echo 'deb ${REPO_URL}/ /' > /etc/apt/sources.list.d/skopeo.list"
curl -fsSL ${REPO_URL}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/skopeo.gpg > /dev/null

sudo apt update
sudo apt install skopeo

I find this preferable to the suggestion above by @natescherer as it uses fewer steps and is easier to read.

@lejouson
Copy link

Following advice from containers/skopeo#1874 (comment), I have got a successful build by setting BUILDX_NO_DEFAULT_ATTESTATIONS.

- name: Pre-build and push image
  uses: devcontainers/ci@v0.3
  env:
    BUILDX_NO_DEFAULT_ATTESTATIONS: true
  with:
    imageName: ghcr.io/${{ github.repository }}
    cacheFrom: ghcr.io/${{ github.repository }}
    platform: linux/amd64,linux/arm64
    push: always

@aaronadamsCA
Copy link
Author

Very nice, that is much cleaner and faster. I can confirm this works for me as well.

Complete working multi-platform build workflow
on: push
jobs:
  devcontainer:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3.5.3

      - uses: docker/login-action@v2.2.0
        with:
          registry: ghcr.io
          username: "${{ github.repository_owner }}"
          password: "${{ github.token }}"

      - uses: docker/setup-qemu-action@v2.2.0
        with:
          platforms: linux/amd64,linux/arm64

      - uses: docker/setup-buildx-action@v2.7.0

      - uses: devcontainers/ci@v0.3.1900000329
        env:
          BUILDX_NO_DEFAULT_ATTESTATIONS: true
        with:
          cacheFrom: "ghcr.io/${{ github.repository }}/devcontainer"
          imageName: "ghcr.io/${{ github.repository }}/devcontainer"
          platform: linux/amd64,linux/arm64
          refFilterForPush: refs/heads/main
          subFolder: .devcontainer

@onedr0p
Copy link

onedr0p commented Jan 23, 2024

It appears that BUILDX_NO_DEFAULT_ATTESTATIONS workaround no longer works. I tried it and I am back to the tagging error again. I had to go back to @zydou method for it to work again.

@chrmarti
Copy link
Collaborator

chrmarti commented Mar 1, 2024

Adding a fix for the tagging error in #271.

I also had to update skopeo to get around the mime type error. Ubuntu 22.04 (the current LTS version) has skopeo 1.4.1, it seems GitHub's ubuntu-latest uses just that. I guess 24.04 might be the next LTS version and I see skopeo 1.9.3 in Ubuntu 23.10. 🤞

@chrmarti chrmarti changed the title Multi-platform build failing on docker tag command Multi-platform build failing due to outdated skopeo in ubuntu-latest Mar 1, 2024
@chrmarti chrmarti self-assigned this Mar 1, 2024
@chrmarti chrmarti added bug Something isn't working upstream labels Mar 1, 2024
metcalfc added a commit to daytonaio/go-devcontainer that referenced this issue Mar 13, 2024
metcalfc added a commit to daytonaio/go-devcontainer that referenced this issue Mar 13, 2024
See: devcontainers/ci#191 (comment)
Signed-off-by: Chad Metcalf <metcalfc@gmail.com>
@onedr0p
Copy link

onedr0p commented Oct 6, 2024

I believe this is fixed now without any additional changes when using

runs-on: ubuntu-24.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests