ARG INSPECTOR_SBOMGEN_VERSION=1.14.3

# Build stage - download and extract the inspector-sbomgen binary
FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:debian12 as build
ARG INSPECTOR_SBOMGEN_VERSION

USER root

WORKDIR /build

RUN apt-get -y update \
  && apt-get -y install wget unzip \
  && wget https://amazon-inspector-sbomgen.s3.amazonaws.com/$INSPECTOR_SBOMGEN_VERSION/linux/amd64/inspector-sbomgen.zip \
  && unzip inspector-sbomgen.zip

# Main stage - copy the inspector-sbomgen binary from the build stage and configure
FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:debian12
ARG INSPECTOR_SBOMGEN_VERSION

LABEL inspector-sbomgen.version=$INSPECTOR_SBOMGEN_VERSION

WORKDIR /var/app

USER root

COPY --from=build /build/inspector-sbomgen-$INSPECTOR_SBOMGEN_VERSION/linux/amd64/inspector-sbomgen /var/app/inspector-sbomgen
RUN chmod +x /var/app/inspector-sbomgen

USER worker

ENTRYPOINT ["/var/app/inspector-sbomgen"]
