@@ -46,25 +46,25 @@ COPY --from=opa-authorizer-builder /tmp/opa-authorizer/dist/opa_authorizer-0.1.0
4646
4747RUN microdnf update \
4848 && microdnf install \
49- cyrus-sasl-devel \
50- # Needed by ./configure to work out SQLite compilation flags, see snippet [1] at the end of file
51- diffutils \
52- # According to https://stackoverflow.com/q/19530974 normally sqlite3 should be shipped with the Python
53- # distribution. However, while addig ARM support we noticed that this does not seem to be the case for the
54- # Python installation shipped in the ARM image variant. So I guess Make is used to find out the sqlite
55- # compilation flags (and propably to not build sqlite from source(?)), see snippet [1] at the end of file
56- make \
57- gcc \
58- gcc-c++ \
59- libffi-devel \
60- openldap-devel \
61- openssl-devel \
62- patch \
63- python${PYTHON} \
64- python${PYTHON}-devel \
65- python${PYTHON}-pip \
66- python${PYTHON}-wheel \
67- libpq-devel \
49+ cyrus-sasl-devel \
50+ # Needed by ./configure to work out SQLite compilation flags, see snippet [1] at the end of file
51+ diffutils \
52+ # According to https://stackoverflow.com/q/19530974 normally sqlite3 should be shipped with the Python
53+ # distribution. However, while addig ARM support we noticed that this does not seem to be the case for the
54+ # Python installation shipped in the ARM image variant. So I guess Make is used to find out the sqlite
55+ # compilation flags (and propably to not build sqlite from source(?)), see snippet [1] at the end of file
56+ make \
57+ gcc \
58+ gcc-c++ \
59+ libffi-devel \
60+ openldap-devel \
61+ openssl-devel \
62+ patch \
63+ python${PYTHON} \
64+ python${PYTHON}-devel \
65+ python${PYTHON}-pip \
66+ python${PYTHON}-wheel \
67+ libpq-devel \
6868 && microdnf clean all && \
6969 rm -rf /var/cache/yum
7070
@@ -74,53 +74,55 @@ RUN microdnf update \
7474RUN python3 -m venv /stackable/app \
7575 && source /stackable/app/bin/activate \
7676 && pip install \
77- --no-cache-dir \
78- --upgrade \
79- setuptools==75.2.0 \
80- pip \
77+ --no-cache-dir \
78+ --upgrade \
79+ setuptools==75.2.0 \
80+ pip \
8181 && pip install \
82- --no-cache-dir \
83- --upgrade \
84- --constraint /tmp/constraints.txt \
85- apache-superset==${PRODUCT} \
86- gevent \
87- psycopg2-binary \
88- statsd \
89- pydruid \
90- python-ldap \
91- 'trino[sqlalchemy]' \
92- # Add optional dependencies for use in custom Superset configurations.
93- # Since https://github.com/stackabletech/superset-operator/pull/530
94- # admins can add custom configuration to superset_conf.py.
95- Flask_OIDC==2.2.0 \
96- Flask-OpenID==1.3.1 \
97- # Redhat has removed `tzdata` from the ubi-minimal images: see https://bugzilla.redhat.com/show_bug.cgi?id=2223028.
98- # Superset relies on ZoneInfo (https://docs.python.org/3/library/zoneinfo.html#data-sources) to resolve time zones, and this is done
99- # by searching first under `TZPATH` (which is empty due to the point above) or for the tzdata python package.
100- # That package is therefore added here (airflow has tzdata in its list of dependencies, but superset does not).
101- tzdata \
82+ --no-cache-dir \
83+ --upgrade \
84+ --constraint /tmp/constraints.txt \
85+ apache-superset==${PRODUCT} \
86+ gevent \
87+ psycopg2-binary \
88+ statsd \
89+ pydruid \
90+ python-ldap \
91+ 'trino[sqlalchemy]' \
92+ # Add optional dependencies for use in custom Superset configurations.
93+ # Since https://github.com/stackabletech/superset-operator/pull/530
94+ # admins can add custom configuration to superset_conf.py.
95+ Flask_OIDC==2.2.0 \
96+ Flask-OpenID==1.3.1 \
97+ # Redhat has removed `tzdata` from the ubi-minimal images: see https://bugzilla.redhat.com/show_bug.cgi?id=2223028.
98+ # Superset relies on ZoneInfo (https://docs.python.org/3/library/zoneinfo.html#data-sources) to resolve time zones, and this is done
99+ # by searching first under `TZPATH` (which is empty due to the point above) or for the tzdata python package.
100+ # That package is therefore added here (airflow has tzdata in its list of dependencies, but superset does not).
101+ tzdata \
102102 # We bumped this from 21.2.0 to 22.0.0 to fix CVE-2024-1135
103103 # Superset 4.1.0 will contain at least 22.0.0, the bump was done in https://github.com/apache/superset/commit/4f693c6db0dc5c7286a36b8d23e90541943ff13f
104104 # We only want to bump this for the 4.0.x line, as the others already have updated and we don't want to accidentially downgrade the version
105105 && if [[ "$PRODUCT" =~ ^4\. 0\. .* ]]; \
106- then echo "Superset 4.0.x detected, installing gunicorn 22.0.0 to fix CVE-2024-1135" \
107- && pip install gunicorn==22.0.0; \
106+ then echo "Superset 4.0.x detected, installing gunicorn 22.0.0 to fix CVE-2024-1135" \
107+ && pip install gunicorn==22.0.0; \
108108 fi \
109109 && pip install \
110- --no-cache-dir \
111- --upgrade \
112- python-json-logger \
113- cyclonedx-bom \
110+ --no-cache-dir \
111+ --upgrade \
112+ python-json-logger \
113+ cyclonedx-bom \
114114 && if [ -n "$AUTHLIB" ]; then pip install Authlib==${AUTHLIB}; fi && \
115115 pip install --no-cache-dir /tmp/opa_authorizer-0.1.0-py3-none-any.whl
116116
117+ COPY --from=statsd_exporter-builder /statsd_exporter/statsd_exporter /stackable/statsd_exporter
117118COPY superset/stackable/patches /patches
118- RUN /patches/apply_patches.sh ${PRODUCT}
119-
120- WORKDIR /stackable
121- RUN source /stackable/app/bin/activate && cyclonedx-py environment --schema-version 1.5 --outfile app/superset-${PRODUCT}.cdx.json
122119
123- COPY --from=statsd_exporter-builder /statsd_exporter/statsd_exporter /stackable/statsd_exporter
120+ RUN <<EOF
121+ /patches/apply_patches.sh ${PRODUCT}
122+ cd /stackable
123+ source /stackable/app/bin/activate && cyclonedx-py environment --schema-version 1.5 --outfile app/superset-${PRODUCT}.cdx.json
124+ chmod --recursive g=u /stackable
125+ EOF
124126
125127# Final image
126128FROM stackable/image/vector
@@ -131,12 +133,12 @@ ARG RELEASE
131133ARG STACKABLE_USER_UID
132134
133135LABEL name="Apache Superset" \
134- 135- vendor="Stackable GmbH" \
136- version="${PRODUCT}" \
137- release="${RELEASE}" \
138- summary="The Stackable image for Apache Superset." \
139- description="This image is deployed by the Stackable Operator for Apache Superset."
136+ 137+ vendor="Stackable GmbH" \
138+ version="${PRODUCT}" \
139+ release="${RELEASE}" \
140+ summary="The Stackable image for Apache Superset." \
141+ description="This image is deployed by the Stackable Operator for Apache Superset."
140142
141143ENV FLASK_APP="superset.app:create_app()" \
142144 FLASK_ENV="production" \
@@ -145,6 +147,10 @@ ENV FLASK_APP="superset.app:create_app()" \
145147ENV PATH="${HOME}/app/bin:${PATH}" \
146148 PYTHONPATH="${HOME}/app/pythonpath"
147149
150+ COPY superset/licenses /licenses
151+
152+ COPY --from=builder --chown=${STACKABLE_USER_UID}:0 /stackable/ ${HOME}/
153+
148154RUN <<EOF
149155microdnf update
150156microdnf install \
@@ -157,22 +163,23 @@ microdnf install \
157163
158164microdnf clean all
159165rm -rf /var/cache/yum
160-
161- # All files and folders owned by root group to support running as arbitrary users.
162- # This is best practice as all container users will belong to the root group (0).
163- chown -R "${STACKABLE_USER_UID}:0" /stackable
164- chmod -R g=u /stackable
165166EOF
166167
167- COPY superset/licenses /licenses
168+ # ----------------------------------------
169+ # Checks
170+ # This section is to run final checks to ensure the created final images
171+ # adhere to several minimal requirements like:
172+ # - check file permissions and ownerships
173+ # ----------------------------------------
168174
169- COPY --from=builder --chown=${STACKABLE_USER_UID}:0 /stackable/ ${HOME}/
175+ # Check that permissions and ownership in /stackable are set correctly
176+ # This will fail and stop the build if any mismatches are found.
177+ RUN <<EOF
178+ /bin/check-permissions-ownership.sh /stackable ${STACKABLE_USER_UID} 0
179+ EOF
170180
171181# ----------------------------------------
172- # Attention: We are changing the group of all files in /stackable directly above
173- # If you do any file based actions (copying / creating etc.) below this comment you
174- # absolutely need to make sure that the correct permissions are applied!
175- # chown ${STACKABLE_USER_UID}:0
182+ # Attention: Do not perform any file based actions (copying/creating etc.) below this comment because the permissions would not be checked.
176183# ----------------------------------------
177184
178185USER ${STACKABLE_USER_UID}
0 commit comments