anchore / syft

CLI tool and library for generating a Software Bill of Materials from container images and filesystems
Apache License 2.0
6.01k stars 553 forks source link

Install Issue - Ubuntu Image on Mac M1 Pro #2870

Open Lachlan-White opened 4 months ago

Lachlan-White commented 4 months ago

What happened: Attempting to build docker image leveraging install script for syft.

What you expected to happen: Syft to be installed

Steps to reproduce the issue:

# Dockerfile for Container
FROM mcr.microsoft.com/powershell:latest

# Install curl for making GitHub API calls
RUN apt-get update && apt-get install -y curl \
    curl \
    git \
    gnupg \
    software-properties-common

# Install Syft
RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin

# Set the working directory
WORKDIR /usr/src/app

# Copy all powershell scripts within folder
COPY *.ps1 .

# Set permissions to execute the script
RUN chmod +x *.ps1

# Set the script as the entry point
CMD ["pwsh", "-File", "run.ps1"]

Anything else we need to know?: Error Message:

=> ERROR [3/6] RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin                                                5.4s
------                                                                                                                                                                         
 > [3/6] RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin:                                                           
2.184 [info] fetching release script for tag='v1.4.1'                                                                                                                          
3.853 [info] using release tag='v1.4.1' version='1.4.1' os='linux' arch='armv7' 
5.331 [error] could not find release asset for os='linux' arch='armv7' format='tar.gz'  
5.337 [error] failed to install syft 
------
dockerfile:12
--------------------
  10 |     
  11 |     # Install Syft
  12 | >>> RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
  13 |     
  14 |     # Set the working directory
--------------------
ERROR: failed to solve: process "/bin/sh -c curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin" did not complete successfully: exit code: 1

Environment:

spiffcs commented 4 months ago

Nice catch @Lachlan-White

It looks like our current .goreleaser.yaml doesn't account for a v7 distribution here.

This section does not exist in our release file:

    # GOARM to build for when GOARCH is arm.
    # For more info refer to: https://go.dev/doc/install/source#environment
    #
    # Default: [ 6 ]
    goarm:
      - 6
      - 7

Reading again, it also looks like we only support arm64 as a release candidate: ARM64 (64-bit): Also known as ARMv8

  - id: linux-build
    dir: ./cmd/syft
    binary: syft
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - ppc64le
      - s390x

To reproduce this I also ran

❯ docker run -it mcr.microsoft.com/powershell:latest /bin/sh
# uname -m
x86_64

It looks like for the powershell latest docker image the arch should be x86_64) arch="amd64" ;;

I was also able to install syft successfully when running that image interactively:

# curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
[info] fetching release script for tag='v1.4.1'
[info] using release tag='v1.4.1' version='1.4.1' os='linux' arch='amd64'
[info] installed /usr/local/bin/syft

Do you have any more information on why your mcr.microsoft.com/powershell:latest /bin/sh is returning an arm32 architecture?

I can talk with the team about updating our release assets, but want to also get to the bottom of why we're seeing different outcomes on our respective machine.

Here is the link to the powershell official docker image along with the tags and their supported architecture: https://hub.docker.com/_/microsoft-powershell

Lachlan-White commented 4 months ago

Hey @spiffcs, thanks for the quick response!

Have no idea why the default output of the Microsoft image is returning an arm32 by default.

I might just force the version specifically in arm64 which would fix my issue, but it is an interesting scenario.

If you had anything you wanted me to test on my local to help, just let me know

spiffcs commented 4 months ago

If you run this on your local what's your result?

docker run  -it mcr.microsoft.com/powershell:latest /bin/sh
# uname -a
Linux 83b1dbc1234f 6.6.26-linuxkit #1 SMP PREEMPT_DYNAMIC Sat Apr 27 04:15:35 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

I copied your Dockerfile and removed the powershell lines and was able to get a successful install.

What happens if you do the same for the alpine version or any explicitly tagged x86_64 arch?

docker run -it mcr.microsoft.com/powershell:lts-alpine-3.17 /bin/sh
Unable to find image 'mcr.microsoft.com/powershell:lts-alpine-3.17' locally
lts-alpine-3.17: Pulling from powershell
3c854c8cbf46: Pull complete
09b3f3175f8c: Pull complete
0505aeb2a439: Pull complete
Digest: sha256:2064d42be1cb05f5d83995f2b12f95737fe74924cbd8519fda886ad834e0b4f8
Status: Downloaded newer image for mcr.microsoft.com/powershell:lts-alpine-3.17
/ # uname -a
Linux aab7448f7e05 6.6.26-linuxkit #1 SMP PREEMPT_DYNAMIC Sat Apr 27 04:15:35 UTC 2024 x86_64 Linux