| 1 |
# Copyright (C) 2025 Siemens |
| 2 |
# |
| 3 |
# SPDX-License-Identifier: MIT |
| 4 |
|
| 5 |
ARG DEBIAN_TAG=trixie-slim |
| 6 |
|
| 7 |
FROM debian:${DEBIAN_TAG} AS debsbom |
| 8 |
|
| 9 |
ARG SOURCE_DATE_EPOCH |
| 10 |
|
| 11 |
ARG DEBIAN_TAG=trixie-slim |
| 12 |
|
| 13 |
ARG TARGETPLATFORM |
| 14 |
ARG DEBIAN_FRONTEND=noninteractive |
| 15 |
ENV LANG=en_US.utf8 |
| 16 |
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 17 |
--mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 18 |
rm -f /etc/apt/apt.conf.d/docker-clean && \ |
| 19 |
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-packages.conf && \ |
| 20 |
if echo "${DEBIAN_TAG}" | grep -q "[0-9]"; then \ |
| 21 |
cp /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources~; \ |
| 22 |
sed -i -e '/^URIs:/d' -e 's|^# http://snapshot\.|URIs: http://snapshot.|' \ |
| 23 |
/etc/apt/sources.list.d/debian.sources; \ |
| 24 |
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/use-snapshot.conf; \ |
| 25 |
echo 'Acquire::Retries "10";' >> /etc/apt/apt.conf.d/use-snapshot.conf; \ |
| 26 |
echo 'Acquire::Retries::Delay::Maximum "600";' >> /etc/apt/apt.conf.d/use-snapshot.conf; \ |
| 27 |
fi && \ |
| 28 |
apt-get update && \ |
| 29 |
apt-get install -y locales && \ |
| 30 |
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ |
| 31 |
apt-get install --no-install-recommends -y \ |
| 32 |
python3-apt python3-cyclonedx-lib python3-debian python3-packageurl \ |
| 33 |
python3-beartype python3-click python3-license-expression \ |
| 34 |
python3-networkx python3-ply \ |
| 35 |
python3-rdflib python3-semantic-version python3-uritools python3-xmltodict \ |
| 36 |
python3-yaml python3-zstandard python3-requests \ |
| 37 |
lz4 \ |
| 38 |
dpkg-dev \ |
| 39 |
xz-utils \ |
| 40 |
bzip2 && \ |
| 41 |
rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache |
| 42 |
|
| 43 |
# install debsbom in a reproducible way |
| 44 |
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 45 |
--mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 46 |
--mount=type=bind,target=/debsbom,rw \ |
| 47 |
apt-get update && \ |
| 48 |
apt-get install --no-install-recommends -y \ |
| 49 |
python3-pip python3-setuptools && \ |
| 50 |
pip3 --proxy=$https_proxy install \ |
| 51 |
--no-deps \ |
| 52 |
--no-build-isolation \ |
| 53 |
--break-system-packages \ |
| 54 |
--root-user-action=ignore \ |
| 55 |
spdx-tools==0.8.3 \ |
| 56 |
/debsbom && \ |
| 57 |
rm -rf $(pip3 cache dir) && \ |
| 58 |
apt-get autopurge -y python3-pip python3-setuptools && \ |
| 59 |
rm -f /etc/apt/apt.conf.d/use-snapshot.conf /etc/apt/apt.conf.d/keep-packages.conf && \ |
| 60 |
if [ -f "/etc/apt/sources.list.d/debian.sources~" ]; then \ |
| 61 |
mv -f /etc/apt/sources.list.d/debian.sources~ /etc/apt/sources.list.d/debian.sources; \ |
| 62 |
fi && \ |
| 63 |
rm -rf /root/.cache /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \ |
| 64 |
debsbom --version |
| 65 |
|
| 66 |
WORKDIR /var/lib/debsbom |