Skip to content

Commit

Permalink
Set non-root default user for Hue images
Browse files Browse the repository at this point in the history
  • Loading branch information
ranade1 committed Apr 19, 2022
1 parent f0fe40d commit 237e38b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tools/container/hue/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ ENV NAME="hue" \
PATH=$PATH:${HUE_BIN} \
SUPERVISOR_VERSION=4.0.2

# create hue user
RUN groupadd -g 1000 ${HUEUSER} && useradd -g 1000 -d ${HUE_HOME} -s /bin/bash -u 1000 ${HUEUSER}
# Switch to non-root default user
RUN yum install -y microdnf && \
microdnf install -y shadow-utils findutils && \
groupadd -g 1000 ${HUEUSER} && \
useradd -g 1000 -d ${HUE_HOME} -s /bin/bash -u 1000 ${HUEUSER}

COPY --chown=${HUEUSER}:${HUEUSER} ${HUEUSER} ${HUE_HOME}
COPY --chown=${HUEUSER}:${HUEUSER} hue.sh ${HUE_HOME}/hue.sh
Expand Down Expand Up @@ -57,5 +60,8 @@ RUN rm -rf ${HUE_HOME}/build/env/lib/python3.8/site-packages/pip/_vendor/chardet

EXPOSE 8888 9111

# Switch to non-root default user
USER hive
ENV USER hive
WORKDIR ${HUE_HOME}
CMD ["/usr/local/bin/supervisord","-c","/etc/supervisord.conf"]
10 changes: 8 additions & 2 deletions tools/container/huelb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ ENV NAME="hue" \
PATH=$PATH:${HUE_BIN} \
SUPERVISOR_VERSION=4.0.2

# create hue user
RUN groupadd -g 1000 ${HUEUSER} && useradd -g 1000 -d ${HUE_HOME} -s /bin/bash -u 1000 ${HUEUSER}
# Switch to non-root default user
RUN yum install -y microdnf && \
microdnf install -y shadow-utils findutils && \
groupadd -g 1000 ${HUEUSER} && \
useradd -g 1000 -d ${HUE_HOME} -s /bin/bash -u 1000 ${HUEUSER}

RUN mkdir -p ${HUE_LOG_DIR} && chown -R ${HUEUSER}:${HUEUSER} ${HUE_LOG_DIR}
RUN echo "Include /etc/httpd/conf.d/hue_httpd.conf" >> /etc/httpd/conf/httpd.conf
Expand All @@ -40,5 +43,8 @@ EXPOSE 8080
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGINT

# Switch to non-root default user
USER hive
ENV USER hive
WORKDIR ${HUE_HOME}
CMD ["run_httpd.sh"]

0 comments on commit 237e38b

Please sign in to comment.