diff --git a/Dockerfile b/Dockerfile index 34d3df69cfd776a61114c0558254933ca9b5d2dd..ed10cf72c6f138c7d674bc1a124e35ff48c80f0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,13 +9,13 @@ RUN rm -rf /var/cache/dnf COPY --from=base /usr/bin/spark-operator /usr/bin/ COPY tini /sbin/ RUN chmod +x /sbin/tini -COPY --from=base /usr/bin/gencerts.sh /usr/bin/ +COPY scripts/gencerts.sh /usr/bin/ RUN chmod +x /usr/bin/gencerts.sh -COPY --from=base /usr/bin/entrypoint.sh /usr/bin/ +COPY scripts/entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh RUN find / -path /proc -prune -o -perm /4000 -exec chmod u-s {} \; RUN find / -path /proc -prune -o -perm /2000 -exec chmod g-s {} \; RUN groupadd -r spark-operator && useradd -r -g spark-operator spark-operator RUN chown -R spark-operator /usr/bin USER spark-operator -ENTRYPOINT ["/usr/bin/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/entrypoint.sh"] diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..f3c83ebade82164dd83c5a90b2b5eb4607daa39e --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# echo commands to the terminal output +set -ex + +# Check whether there is a passwd entry for the container UID +myuid=$(id -u) +mygid=$(id -g) +# turn off -e for getent because it will return error code in anonymous uid case +set +e +uidentry=$(getent passwd $myuid) +set -e + +echo $myuid +echo $mygid +echo $uidentry + +# If there is no passwd entry for the container UID, attempt to create one +if [[ -z "$uidentry" ]] ; then + if [[ -w /etc/passwd ]] ; then + echo "$myuid:x:$myuid:$mygid:anonymous uid:$SPARK_HOME:/bin/false" >> /etc/passwd + else + echo "Container ENTRYPOINT failed to add passwd entry for anonymous UID" + fi +fi + +exec /usr/bin/tini -s -- /usr/bin/spark-operator "$@"