Skip to content

Commit a4e2f99

Browse files
committed
fix: remove circular dependencies in Airflow SBOM
1 parent 99e8933 commit a4e2f99

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

airflow/Dockerfile

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ FROM stackable/image/statsd_exporter AS statsd_exporter-builder
1212
FROM stackable/image/vector AS airflow-build-image
1313

1414
ARG PRODUCT
15+
ARG STATSD_EXPORTER
1516
ARG PYTHON
1617
ARG TARGETARCH
1718

@@ -38,20 +39,40 @@ RUN microdnf update && \
3839
python${PYTHON}-pip \
3940
python${PYTHON}-wheel \
4041
# The airflow odbc provider can compile without the development files (headers and libraries) (see https://github.com/stackabletech/docker-images/pull/683)
41-
unixODBC && \
42+
unixODBC \
43+
# Needed to modify the SBOM
44+
jq && \
4245
microdnf clean all && \
4346
rm -rf /var/cache/yum
4447

45-
RUN python${PYTHON} -m venv --system-site-packages /stackable/app && \
46-
source /stackable/app/bin/activate && \
47-
pip install --no-cache-dir --upgrade pip && \
48-
pip install --no-cache-dir apache-airflow[${AIRFLOW_EXTRAS}]==${PRODUCT} --constraint /tmp/constraints.txt && \
49-
# Needed for pandas S3 integration to e.g. write and read csv and parquet files to/from S3
50-
pip install --no-cache-dir s3fs cyclonedx-bom && \
51-
cyclonedx-py environment --schema-version 1.5 --outfile /stackable/airflow-${PRODUCT}.cdx.json
48+
RUN <<EOF
49+
python${PYTHON} -m venv --system-site-packages /stackable/app
50+
51+
source /stackable/app/bin/activate
52+
53+
pip install --no-cache-dir --upgrade pip
54+
pip install --no-cache-dir apache-airflow[${AIRFLOW_EXTRAS}]==${PRODUCT} --constraint /tmp/constraints.txt
55+
# Needed for pandas S3 integration to e.g. write and read csv and parquet files to/from S3
56+
pip install --no-cache-dir s3fs cyclonedx-bom
57+
58+
# Create the SBOM for Airflow
59+
# Important: All `pip install` commands must be above this line, otherwise the SBOM will be incomplete
60+
cyclonedx-py environment --schema-version 1.5 --outfile /tmp/sbom.json
61+
62+
# Break circular dependencies by removing the apache-airflow dependency from the providers
63+
jq '.dependencies |= map(if .ref | test("^apache-airflow-providers-") then
64+
.dependsOn |= map(select(. != "apache-airflow==${PRODUCT}"))
65+
else
66+
.
67+
end)' /tmp/sbom.json > /stackable/airflow-${PRODUCT}.cdx.json
68+
69+
rm /tmp/sbom.json
70+
microdnf remove jq
71+
EOF
5272

5373
WORKDIR /stackable
5474
COPY --from=statsd_exporter-builder /statsd_exporter/statsd_exporter /stackable/statsd_exporter
75+
COPY --from=statsd_exporter-builder /statsd_exporter/statsd_exporter-${STATSD_EXPORTER}.cdx.json /stackable/statsd_exporter-${STATSD_EXPORTER}.cdx.json
5576

5677
FROM stackable/image/vector AS airflow-main-image
5778

0 commit comments

Comments
 (0)