Skip to content

Commit 1b1947e

Browse files
committed
WIP
1 parent 36ec2db commit 1b1947e

File tree

3 files changed

+61
-45
lines changed

3 files changed

+61
-45
lines changed

airflow/Dockerfile

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG GIT_SYNC
44

55
# For updated versions check https://github.com/kubernetes/git-sync/releases
66
# which should contain a image location (e.g. registry.k8s.io/git-sync/git-sync:v3.6.8)
7-
FROM oci.stackable.tech/sdp/git-sync:${GIT_SYNC} as gitsync-image
7+
FROM oci.stackable.tech/sdp/git-sync:${GIT_SYNC} AS gitsync-image
88

99
FROM stackable/image/statsd_exporter AS statsd_exporter-builder
1010

@@ -60,9 +60,10 @@ ARG RELEASE
6060
ARG TINI
6161
ARG TARGETARCH
6262
ARG TARGETOS
63+
ARG STACKABLE_USER_UID
6364

6465
LABEL name="Apache Airflow" \
65-
maintainer="info@stackable.tech" \
66+
maintainer="info@stackastatsd_exporble.tech" \
6667
vendor="Stackable GmbH" \
6768
version="${PRODUCT}" \
6869
release="${RELEASE}" \
@@ -71,50 +72,56 @@ LABEL name="Apache Airflow" \
7172

7273
COPY airflow/licenses /licenses
7374

75+
COPY --chown=${STACKABLE_USER_UID}:0 airflow/stackable/utils/entrypoint.sh /entrypoint.sh
76+
COPY --chown=${STACKABLE_USER_UID}:0 airflow/stackable/utils/run-airflow.sh /run-airflow.sh
77+
7478
# Update image and install python
75-
RUN microdnf update && \
76-
microdnf install \
77-
ca-certificates \
78-
cyrus-sasl \
79-
git \
80-
libpq \
81-
openldap \
82-
openldap-clients \
83-
openssh-clients \
84-
openssl-libs \
85-
openssl-pkcs11 \
86-
python${PYTHON} \
87-
socat \
88-
unixODBC && \
89-
microdnf clean all && \
90-
rm -rf /var/cache/yum
79+
RUN <<EOF
80+
microdnf update
81+
microdnf install
82+
ca-certificates
83+
cyrus-sasl
84+
git
85+
libpq
86+
openldap
87+
openldap-clients
88+
openssh-clients
89+
openssl-libs
90+
openssl-pkcs11
91+
python${PYTHON}
92+
socat
93+
unixODBC
94+
microdnf clean all
95+
rm -rf /var/cache/yum
96+
97+
# Get the correct `tini` binary for our architecture.
98+
# It is used as an init alternative in the entrypoint
99+
curl --fail -o /usr/bin/tini "https://repo.stackable.tech/repository/packages/tini/tini-${TINI}-${TARGETARCH}"
100+
chmod a+x /entrypoint.sh
101+
chmod a+x /run-airflow.sh
102+
chmod +x /usr/bin/tini
103+
EOF
91104

92105
ENV HOME=/stackable
93106
ENV AIRFLOW_USER_HOME_DIR=/stackable
94107
ENV PATH=$PATH:/bin:$HOME/app/bin
95108
ENV AIRFLOW_HOME=$HOME/airflow
96109

97-
98-
# Get the correct `tini` binary for our architecture.
99-
# It is used as an init alternative in the entrypoint
100-
RUN mkdir -pv ${AIRFLOW_HOME} && \
101-
mkdir -pv ${AIRFLOW_HOME}/dags && \
102-
mkdir -pv ${AIRFLOW_HOME}/logs && \
103-
chown --recursive stackable:stackable ${AIRFLOW_HOME} && \
104-
curl --fail -o /usr/bin/tini "https://repo.stackable.tech/repository/packages/tini/tini-${TINI}-${TARGETARCH}"
105-
106-
COPY airflow/stackable/utils/entrypoint.sh /entrypoint.sh
107-
COPY airflow/stackable/utils/run-airflow.sh /run-airflow.sh
108-
RUN chmod a+x /entrypoint.sh && \
109-
chmod a+x /run-airflow.sh && \
110-
chmod +x /usr/bin/tini
111-
112-
COPY --from=airflow-build-image --chown=stackable:stackable /stackable/ ${HOME}/
113-
COPY --from=gitsync-image --chown=stackable:stackable /git-sync /stackable/git-sync
114-
115-
USER stackable
110+
USER ${STACKABLE_USER_UID}
116111
WORKDIR /stackable
117112

113+
COPY --from=airflow-build-image --chown=${STACKABLE_USER_UID}:0 /stackable/ ${HOME}/
114+
COPY --from=gitsync-image --chown=${STACKABLE_USER_UID}:0 /git-sync /stackable/git-sync
115+
116+
RUN <<EOF
117+
mkdir -pv ${AIRFLOW_HOME}
118+
mkdir -pv ${AIRFLOW_HOME}/dags
119+
mkdir -pv ${AIRFLOW_HOME}/logs
120+
121+
chgrp -R 0 /stackable
122+
chmod -R g=u /stackable
123+
EOF
124+
118125
ENTRYPOINT ["/usr/bin/tini", "--", "/run-airflow.sh"]
119126
CMD []
120127

conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@
8989
"ignore-error": "true",
9090
},
9191
]
92+
93+
args = {
94+
"STACKABLE_USER_NAME": "stackable",
95+
"STACKABLE_USER_UID": "1000",
96+
"STACKABLE_USER_GID": "1000"
97+
}

stackable-base/Dockerfile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal@sha256:104cf11d890aeb7dd5728b7d
4141

4242
# intentionally unused
4343
ARG PRODUCT
44+
ARG STACKABLE_USER_UID
45+
ARG STACKABLE_USER_GID
46+
ARG STACKABLE_USER_NAME
4447

4548
# Sets the default shell to Bash with strict error handling and robust pipeline processing.
4649
# "-e": Exits immediately if a command exits with a non-zero status
@@ -102,7 +105,7 @@ microdnf install \
102105
###
103106
# Added only temporarily to create the user and group, removed again below
104107
microdnf install shadow-utils
105-
groupadd --gid 1000 --system stackable
108+
groupadd --gid ${STACKABLE_USER_GID} --system ${STACKABLE_USER_NAME}
106109

107110
# The --no-log-init is required to work around a bug/problem in Go/Docker when very large UIDs are used
108111
# See https://github.com/moby/moby/issues/5419#issuecomment-41478290 for more context
@@ -111,12 +114,12 @@ groupadd --gid 1000 --system stackable
111114
# We can safely ignore this warning, to get rid of the warning we could change /etc/login.defs but that does not seem worth it
112115
useradd \
113116
--no-log-init \
114-
--gid stackable \
115-
--uid 1000 \
117+
--gid ${STACKABLE_USER_GID} \
118+
--uid ${STACKABLE_USER_UID} \
116119
--system \
117120
--create-home \
118121
--home-dir /stackable \
119-
stackable
122+
${STACKABLE_USER_NAME}
120123
microdnf remove shadow-utils
121124
microdnf clean all
122125

@@ -132,8 +135,8 @@ microdnf clean all
132135

133136
echo -e "if [ -f ~/.bashrc ]; then\n\tsource ~/.bashrc\nfi" >> /stackable/.profile
134137

135-
chown stackable:stackable /stackable/.bashrc
136-
chown stackable:stackable /stackable/.profile
138+
chown ${STACKABLE_USER_UID}:0 /stackable/.bashrc
139+
chown ${STACKABLE_USER_UID}:0 /stackable/.profile
137140

138141
# CVE-2023-37920: Remove "e-Tugra" root certificates
139142
# e-Tugra's root certificates were subject to an investigation prompted by reporting of security issues in their systems
@@ -156,8 +159,8 @@ if [ "$(trust list --filter=ca-anchors | grep -c 'E-Tugra')" != "0" ]; then
156159
fi
157160
EOF
158161

159-
COPY --from=product-utils-builder --chown=stackable:stackable /config-utils/target/release/config-utils /stackable/config-utils
160-
COPY --from=product-utils-builder --chown=stackable:stackable /config-utils/config-utils.cdx.xml /stackable/config-utils.cdx.xml
162+
COPY --from=product-utils-builder --chown=${STACKABLE_USER_UID}:0 /config-utils/target/release/config-utils /stackable/config-utils
163+
COPY --from=product-utils-builder --chown=${STACKABLE_USER_UID}:0 /config-utils/config-utils.cdx.xml /stackable/config-utils.cdx.xml
161164
ENV PATH="${PATH}:/stackable"
162165

163166
# These labels have mostly been superceded by the OpenContainer spec annotations below but it doesn't hurt to include them

0 commit comments

Comments
 (0)