Skip to content

Make uid/gid configurable & change group of files - part 3 #897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ All notable changes to this project will be documented in this file.
- Enable [Docker build checks](https://docs.docker.com/build/checks/) ([#872]).
- java: migrate to temurin jdk/jre ([#894]).
- tools: bump kubectl to `1.31.1` and jq to `1.7.1` ([#896]).
- Make username, user id, group id configurable, use numeric ids everywhere, change group of all files to 0 ([#849], [#890]).
- Make username, user id, group id configurable, use numeric ids everywhere, change group of all files to 0 ([#849], [#890], [#897]).
- ci: Bump `stackabletech/actions` to 0.0.7 ([#901], [#903]).

### Removed
Expand Down Expand Up @@ -87,6 +87,7 @@ All notable changes to this project will be documented in this file.
[#890]: https://github.com/stackabletech/docker-images/pull/890
[#894]: https://github.com/stackabletech/docker-images/pull/894
[#896]: https://github.com/stackabletech/docker-images/pull/896
[#897]: https://github.com/stackabletech/docker-images/pull/897
[#898]: https://github.com/stackabletech/docker-images/pull/898
[#901]: https://github.com/stackabletech/docker-images/pull/901
[#903]: https://github.com/stackabletech/docker-images/pull/903
Expand Down
7 changes: 7 additions & 0 deletions airflow/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
WORKDIR /stackable

Expand Down
7 changes: 7 additions & 0 deletions druid/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
ENV PATH="${PATH}":/stackable/druid/bin

Expand Down
7 changes: 7 additions & 0 deletions hadoop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ EOF

COPY hadoop/licenses /licenses

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}

ENV HOME=/stackable
Expand Down
7 changes: 7 additions & 0 deletions hbase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
ENV HBASE_CONF_DIR=/stackable/hbase/conf
ENV HOME=/stackable
Expand Down
7 changes: 7 additions & 0 deletions hello-world/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
WORKDIR /stackable

Expand Down
7 changes: 7 additions & 0 deletions hive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ EOF
COPY --chown=${STACKABLE_USER_UID}:0 --from=hive-builder /stackable/jmx /stackable/jmx
COPY hive/licenses /licenses

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}

ENV HADOOP_HOME=/stackable/hadoop
Expand Down
7 changes: 7 additions & 0 deletions kafka/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}

ENV PATH="${PATH}:/stackable/bin:/stackable/kafka/bin"
Expand Down
7 changes: 7 additions & 0 deletions nifi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}

ENV HOME=/stackable
Expand Down
7 changes: 7 additions & 0 deletions omid/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
WORKDIR /stackable/omid-tso-server

Expand Down
7 changes: 7 additions & 0 deletions opa/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
WORKDIR /stackable/opa

Expand Down
7 changes: 7 additions & 0 deletions spark-k8s/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}

WORKDIR /stackable/spark
Expand Down
2 changes: 1 addition & 1 deletion stackable-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ chown ${STACKABLE_USER_UID}:0 /stackable/.bashrc
chown ${STACKABLE_USER_UID}:0 /stackable/.profile

cp /root/.curlrc /stackable/.curlrc
chown stackable:0 /stackable/.curlrc
chown ${STACKABLE_USER_UID}:0 /stackable/.curlrc

# CVE-2023-37920: Remove "e-Tugra" root certificates
# e-Tugra's root certificates were subject to an investigation prompted by reporting of security issues in their systems
Expand Down
3 changes: 2 additions & 1 deletion statsd_exporter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

FROM stackable/image/stackable-base
ARG PRODUCT
ARG STACKABLE_USER_UID

WORKDIR /statsd_exporter

RUN --mount=type=cache,id=go-statsd-exporter,uid=1000,target=/go_cache <<EOF
RUN --mount=type=cache,id=go-statsd-exporter,uid=${STACKABLE_USER_UID},target=/go_cache <<EOF
microdnf update

# Tar and gzip are used to unpack the statsd_exporter source
Expand Down
40 changes: 28 additions & 12 deletions superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ FROM stackable/image/vector
ARG PRODUCT
ARG PYTHON
ARG RELEASE
ARG STACKABLE_USER_UID

LABEL name="Apache Superset" \
maintainer="info@stackable.tech" \
Expand All @@ -105,22 +106,37 @@ ENV FLASK_APP="superset.app:create_app()" \
ENV PATH="${HOME}/app/bin:${PATH}" \
PYTHONPATH="${HOME}/app/pythonpath"

RUN microdnf update \
&& microdnf install \
cyrus-sasl \
openldap \
openldap-clients \
openssl-libs \
openssl-pkcs11 \
python${PYTHON} \
&& microdnf clean all && \
rm -rf /var/cache/yum
RUN <<EOF
microdnf update
microdnf install \
cyrus-sasl \
openldap \
openldap-clients \
openssl-libs \
openssl-pkcs11 \
"python${PYTHON}"

microdnf clean all
rm -rf /var/cache/yum

# All files and folders owned by root group to support running as arbitrary users.
# This is best practice as all container users will belong to the root group (0).
chown -R "${STACKABLE_USER_UID}:0" /stackable
chmod -R g=u /stackable
EOF

COPY superset/licenses /licenses

COPY --from=builder --chown=stackable:stackable /stackable/ ${HOME}/
COPY --from=builder --chown=${STACKABLE_USER_UID}:0 /stackable/ ${HOME}/

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER stackable
USER ${STACKABLE_USER_UID}
WORKDIR ${HOME}

CMD ["/bin/sh", "-c", \
Expand Down
33 changes: 24 additions & 9 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ARG KUBECTL_VERSION
ARG RELEASE
ARG JQ_VERSION
ARG TARGETARCH
ARG STACKABLE_USER_UID

LABEL name="Stackable Tools" \
maintainer="info@stackable.tech" \
Expand All @@ -30,16 +31,30 @@ RUN microdnf update && \

COPY tools/licenses /licenses

USER stackable
WORKDIR /stackable/bin
ENV PATH=/stackable/bin:$PATH

# Get latest stable version from curl -L -s https://dl.k8s.io/release/stable.txt
RUN curl https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl \
-o /stackable/bin/kubectl && chmod +x /stackable/bin/kubectl

RUN curl https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 \
-o /stackable/bin/jq && \
chmod +x /stackable/bin/jq

USER stackable
RUN <<EOF
curl "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/${TARGETARCH}/kubectl" \
-o /stackable/bin/kubectl
chmod +x /stackable/bin/kubectl

curl "https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64" \
-o /stackable/bin/jq
chmod +x /stackable/bin/jq

# All files and folders owned by root group to support running as arbitrary users.
# This is best practice as all container users will belong to the root group (0).
chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
24 changes: 19 additions & 5 deletions trino-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM stackable/image/java-base

ARG PRODUCT
ARG RELEASE
ARG STACKABLE_USER_UID

LABEL name="Trino CLI" \
maintainer="info@stackable.tech" \
Expand All @@ -22,14 +23,27 @@ RUN microdnf update && \
microdnf clean all && \
rm -rf /var/cache/yum

USER stackable
WORKDIR /stackable

COPY --chown=stackable:stackable trino-cli/licenses /licenses
COPY --chown=${STACKABLE_USER_UID}:0 trino-cli/licenses /licenses

WORKDIR /stackable/trino-cli

RUN curl -O https://repo.stackable.tech/repository/packages/trino-cli/trino-cli-${PRODUCT}-executable.jar \
&& ln -s trino-cli-${PRODUCT}-executable.jar trino-cli-executable.jar
RUN <<EOF
curl -O "https://repo.stackable.tech/repository/packages/trino-cli/trino-cli-${PRODUCT}-executable.jar"
ln -s "trino-cli-${PRODUCT}-executable.jar" trino-cli-executable.jar

# All files and folders owned by root group to support running as arbitrary users.
# This is best practice as all container users will belong to the root group (0).
chown -R ${STACKABLE_USER_UID}:0 /stackable
chmod -R g=u /stackable
EOF

# ----------------------------------------
# Attention: We are changing the group of all files in /stackable directly above
# If you do any file based actions (copying / creating etc.) below this comment you
# absolutely need to make sure that the correct permissions are applied!
# chown ${STACKABLE_USER_UID}:0
# ----------------------------------------

USER ${STACKABLE_USER_UID}
ENTRYPOINT ["java", "-jar", "/stackable/trino-cli/trino-cli-executable.jar"]
Loading