1- FROM alpine:latest AS start
1+ ARG BUILDKIT_SBOM_SCAN_STAGE=base
2+
3+ FROM alpine:latest AS base
24
35ARG SBOM_PACKAGES="\
4- linux-headers \
56 openssl-dev \
67 openssl-libs-static \
78 libcap-dev \
@@ -16,6 +17,10 @@ ARG SBOM_PACKAGES="\
1617 musl \
1718 musl-dev"
1819
20+ RUN apk add --no-cache \
21+ ${SBOM_PACKAGES}
22+
23+ FROM base AS start
1924RUN apk add --no-cache \
2025 build-base \
2126 curl \
@@ -26,8 +31,8 @@ RUN apk add --no-cache \
2631 automake \
2732 ed \
2833 bash \
29- cppunit \
30- ${SBOM_PACKAGES}
34+ linux-headers \
35+ cppunit
3136
3237ARG SQUID_VERSION=7.4
3338
@@ -157,7 +162,7 @@ RUN export PKG_CONFIG="pkg-config --static" && \
157162 --without-gssapi \
158163 --with-libcap && \
159164 make -j$(nproc) && \
160- make install-strip DESTDIR=/app
165+ make install-strip DESTDIR=/app man8dir=
161166
162167RUN echo "proxy:x:1000:1000:proxy,,,:/nonexistent:/bin/false" > /app/passwd && \
163168 echo "proxy:x:1000:" > /app/group
@@ -175,32 +180,12 @@ COPY squid-init.c /src/
175180RUN gcc -no-pie -static -pipe -O2 -o /app/usr/sbin/squid-init squid-init.c \
176181 && strip --strip-all --remove-section=.comment --remove-section=.note /app/usr/sbin/squid-init
177182
178- # Create the 'Shadow Root'
179- # We install ONLY the library packages here.
180- # This creates a clean APK database at /sbom-root/lib/apk/db
181- RUN mkdir -p /sbom-root && \
182- apk add --root /sbom-root \
183- --initdb \
184- --no-script \
185- --no-cache \
186- --repositories-file /etc/apk/repositories \
187- --keys-dir /etc/apk/keys \
188- ${SBOM_PACKAGES}
189-
190- # Run Syft against the Shadow Root
191- # We save the result to a known location.
192- RUN curl -LsS "https://raw.githubusercontent.com/anchore/syft/main/install.sh" | sh -s -- -b /usr/local/bin \
193- && syft dir:/sbom-root \
194- --output spdx-json=/app/sbom.spdx.json \
195- --source-name "squid" \
196- --source-version "${SQUID_VERSION}"
197-
198183# --- Final Stage ---
199184FROM scratch AS final
200185
201186COPY --from=builder /app/ /
202187COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
203- COPY --from=builder /app/sbom.spdx.json /sbom.spdx.json
188+ # COPY --from=builder /app/sbom.spdx.json /sbom.spdx.json
204189
205190COPY --from=builder /app/passwd /etc/passwd
206191COPY --from=builder /app/group /etc/group
0 commit comments