Skip to content
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

NO-JIRA fix Dockerfile security #736

Closed
Closed
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
16 changes: 10 additions & 6 deletions community-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LABEL io.openshift.non-scalable=true
LABEL io.openshift.tags=sonarqube,static-code-analysis,code-quality,clean-code
LABEL org.opencontainers.image.url=https://github.com/SonarSource/docker-sonarqube

SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "xtrace", "-c"]

ENV LANG='en_US.UTF-8' \
LANGUAGE='en_US:en' \
LC_ALL='en_US.UTF-8'
Expand All @@ -28,9 +30,9 @@ ENV DOCKER_RUNNING="true" \
# Separate stage to use variable expansion
ENV ES_TMPDIR="${SQ_TEMP_DIR}"

RUN set -eux; \
deluser ubuntu; \
useradd --system --uid 1000 --gid 0 sonarqube; \
RUN deluser ubuntu; \
groupadd --gid 3000 sonarqube; \
useradd --uid 1000 --gid 3000 sonarqube; \
apt-get update; \
apt-get --no-install-recommends -y install \
bash \
Expand Down Expand Up @@ -63,14 +65,16 @@ RUN set -eux; \
apt-get remove -y gnupg unzip; \
rm -rf /var/lib/apt/lists/*;

VOLUME ["${SQ_DATA_DIR}", "${SQ_EXTENSIONS_DIR}", "${SQ_LOGS_DIR}", "${SQ_TEMP_DIR}"]

COPY entrypoint.sh ${SONARQUBE_HOME}/docker/

RUN chown -R sonarqube:sonarqube /opt/sonarqube
USER sonarqube

VOLUME ["${SQ_DATA_DIR}", "${SQ_EXTENSIONS_DIR}", "${SQ_LOGS_DIR}", "${SQ_TEMP_DIR}"]

WORKDIR ${SONARQUBE_HOME}
EXPOSE 9000

USER sonarqube
STOPSIGNAL SIGINT

ENTRYPOINT ["/opt/sonarqube/docker/entrypoint.sh"]