From 00d24164db7d667f03c9d1adefeffaf81984a6ad Mon Sep 17 00:00:00 2001 From: Steve Smith Date: Tue, 6 Aug 2019 14:19:28 +1000 Subject: [PATCH] DCD-545: Import config templates from Ansible, and expand and normalise the two Dockerfiles with limited permissions. --- Dockerfile | 33 ++++++++----- Dockerfile-alpine | 37 +++++++++------ config/confluence-init.properties.j2 | 1 + config/confluence.cfg.xml.j2 | 42 +++++++++++++++++ config/seraph-config.xml.j2 | 69 +++++++++++++++++++++++++++ config/server.xml.j2 | 70 ++++++++++++++++++++++++++++ 6 files changed, 227 insertions(+), 25 deletions(-) create mode 100644 config/confluence-init.properties.j2 create mode 100644 config/confluence.cfg.xml.j2 create mode 100644 config/seraph-config.xml.j2 create mode 100644 config/server.xml.j2 diff --git a/Dockerfile b/Dockerfile index 2bdfa14..b83f757 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,10 @@ FROM adoptopenjdk/openjdk8:slim +MAINTAINER Atlassian Confluence -ENV RUN_USER daemon -ENV RUN_GROUP daemon +ENV RUN_USER confluence +ENV RUN_GROUP confluence +ENV RUN_UID 2002 +ENV RUN_GID 2002 # https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence @@ -15,24 +18,32 @@ EXPOSE 8090 EXPOSE 8091 CMD ["/entrypoint.sh", "-fg"] -ENTRYPOINT ["/tini", "--"] +ENTRYPOINT ["/sbin/tini", "--"] RUN apt-get update \ && apt-get install -y --no-install-recommends fontconfig \ && apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* ARG TINI_VERSION=v0.18.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini -RUN chmod +x /tini +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini +RUN chmod +x /sbin/tini COPY entrypoint.sh /entrypoint.sh +COPY scripts/* /opt/atlassian/bin/ +COPY config/* /opt/atlassian/etc/ ARG CONFLUENCE_VERSION ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-${CONFLUENCE_VERSION}.tar.gz -RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ - && curl -L --silent ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${CONFLUENCE_INSTALL_DIR}" \ - && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ - && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ - && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml \ - && sed -i -e 's/Context path=""/Context path="${catalinaContextPath}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml +RUN groupadd --gid ${RUN_GID} ${RUN_GROUP} \ + && useradd --uid ${RUN_UID} --gid ${RUN_GID} --home-dir ${CONFLUENCE_HOME} ${RUN_USER} \ + \ + && mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L --silent ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${CONFLUENCE_INSTALL_DIR}" \ + && chmod -R "u=rwX,g=rX,o=rX" ${CONFLUENCE_INSTALL_DIR}/ \ + && chown -R root. ${CONFLUENCE_INSTALL_DIR}/ \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/logs \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/temp \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/work \ + \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh diff --git a/Dockerfile-alpine b/Dockerfile-alpine index a16f387..ae48145 100644 --- a/Dockerfile-alpine +++ b/Dockerfile-alpine @@ -1,21 +1,22 @@ FROM adoptopenjdk/openjdk8:alpine MAINTAINER Atlassian Confluence -ENV RUN_USER daemon -ENV RUN_GROUP daemon +ENV RUN_USER confluence +ENV RUN_GROUP confluence +ENV RUN_UID 2002 +ENV RUN_GID 2002 # https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html -ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence -ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence +ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence +ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence VOLUME ["${CONFLUENCE_HOME}"] +WORKDIR $CONFLUENCE_HOME # Expose HTTP and Synchrony ports EXPOSE 8090 EXPOSE 8091 -WORKDIR $CONFLUENCE_HOME - CMD ["/entrypoint.sh", "-fg"] ENTRYPOINT ["/sbin/tini", "--"] @@ -27,14 +28,22 @@ RUN ln -s /usr/lib/libfontconfig.so.1 /usr/lib/libfontconfig.so \ && ln -s /lib/libc.musl-x86_64.so.1 /usr/lib/libc.musl-x86_64.so.1 ENV LD_LIBRARY_PATH /usr/lib -COPY entrypoint.sh /entrypoint.sh +COPY entrypoint.sh /entrypoint.sh +COPY scripts/* /opt/atlassian/bin/ +COPY config/* /opt/atlassian/etc/ ARG CONFLUENCE_VERSION -ARG DOWNLOAD_URL=http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${CONFLUENCE_VERSION}.tar.gz +ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-${CONFLUENCE_VERSION}.tar.gz -RUN mkdir -p ${CONFLUENCE_INSTALL_DIR} \ - && curl -L --silent ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$CONFLUENCE_INSTALL_DIR" \ - && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/ \ - && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh \ - && sed -i -e 's/port="8090"/port="8090" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml \ - && sed -i -e 's/Context path=""/Context path="${catalinaContextPath}"/' ${CONFLUENCE_INSTALL_DIR}/conf/server.xml +RUN addgroup -g ${RUN_GID} ${RUN_GROUP} \ + && adduser -u ${RUN_UID} -G ${RUN_GROUP} -h ${CONFLUENCE_HOME} -D ${RUN_USER} \ + \ + && mkdir -p ${CONFLUENCE_INSTALL_DIR} \ + && curl -L --silent ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${CONFLUENCE_INSTALL_DIR}" \ + && chmod -R "u=rwX,g=rX,o=rX" ${CONFLUENCE_INSTALL_DIR}/ \ + && chown -R root. ${CONFLUENCE_INSTALL_DIR}/ \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/logs \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/temp \ + && chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/work \ + \ + && sed -i -e 's/-Xms\([0-9]\+[kmg]\) -Xmx\([0-9]\+[kmg]\)/-Xms\${JVM_MINIMUM_MEMORY:=\1} -Xmx\${JVM_MAXIMUM_MEMORY:=\2} \${JVM_SUPPORT_RECOMMENDED_ARGS} -Dconfluence.home=\${CONFLUENCE_HOME}/g' ${CONFLUENCE_INSTALL_DIR}/bin/setenv.sh diff --git a/config/confluence-init.properties.j2 b/config/confluence-init.properties.j2 new file mode 100644 index 0000000..b2ecc60 --- /dev/null +++ b/config/confluence-init.properties.j2 @@ -0,0 +1 @@ +confluence.home = {{ atl_product_home }} diff --git a/config/confluence.cfg.xml.j2 b/config/confluence.cfg.xml.j2 new file mode 100644 index 0000000..4b5368c --- /dev/null +++ b/config/confluence.cfg.xml.j2 @@ -0,0 +1,42 @@ + + + + + setupstart + custom + 0 + + + postgresql + database-type-standard + com.atlassian.confluence.impl.hibernate.dialect.PostgreSQLDialect + ${localHome}/temp + ${confluenceHome}/attachments + + {{ atl_db_driver }} + {{ atl_jdbc_url }} + {{ atl_jdbc_user }} + {{ atl_jdbc_password }} + {{ atl_db_poolminsize }} + {{ atl_db_poolmaxsize }} + {{ atl_db_timeout }} + {{ atl_db_idletestperiod }} + {{ atl_db_maxstatements }} + {{ atl_db_validate }} + {{ atl_db_acquireincrement }} + select version(); + + {{ atl_product_home_shared }} + true + {{ atl_product_home_shared }} + {{ atl_hazelcast_network_aws_iam_role }} + {{ atl_hazelcast_network_aws_iam_region }} + {{ atl_hazelcast_network_aws_host_header }} + {{ atl_hazelcast_network_aws_tag_key }} + {{ atl_hazelcast_network_aws_tag_value }} + aws + {{ atl_aws_stack_name }} + 1 + + + diff --git a/config/seraph-config.xml.j2 b/config/seraph-config.xml.j2 new file mode 100644 index 0000000..8b16d54 --- /dev/null +++ b/config/seraph-config.xml.j2 @@ -0,0 +1,69 @@ + + + + login.url + /login.action?os_destination=${originalurl}&permissionViolation=true + + + link.login.url + /login.action + + + cookie.encoding + cNf + + + login.cookie.key + seraph.confluence + + + + autologin.cookie.age + {{ atl_autologin_cookie_age }} + + + + + authentication.type + os_authType + + + + + invalidate.session.on.login + true + + + + invalidate.session.exclude.list + + + + + + + + + + + + + + + + + + + + + + config.file + seraph-paths.xml + + + + + + + diff --git a/config/server.xml.j2 b/config/server.xml.j2 new file mode 100644 index 0000000..e11cb8b --- /dev/null +++ b/config/server.xml.j2 @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +