mirror of
https://bitbucket.org/atlassian-docker/docker-atlassian-confluence-server.git
synced 2024-08-30 18:22:16 +00:00
Integrate shared components in Docker build
This commit is contained in:
parent
0548cc13b4
commit
90e0a7f7b9
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "shared-components"]
|
||||||
|
path = shared-components
|
||||||
|
url = https://bitbucket.org/atlassian-docker/docker-shared-components.git
|
38
Dockerfile
38
Dockerfile
@ -1,14 +1,14 @@
|
|||||||
ARG BASE_IMAGE=adoptopenjdk:11-hotspot
|
ARG BASE_IMAGE=adoptopenjdk:11-hotspot
|
||||||
FROM $BASE_IMAGE
|
FROM $BASE_IMAGE
|
||||||
|
|
||||||
ENV RUN_USER confluence
|
ENV RUN_USER confluence
|
||||||
ENV RUN_GROUP confluence
|
ENV RUN_GROUP confluence
|
||||||
ENV RUN_UID 2002
|
ENV RUN_UID 2002
|
||||||
ENV RUN_GID 2002
|
ENV RUN_GID 2002
|
||||||
|
|
||||||
# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html
|
# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html
|
||||||
ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence
|
ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence
|
||||||
ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence
|
ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence
|
||||||
|
|
||||||
WORKDIR $CONFLUENCE_HOME
|
WORKDIR $CONFLUENCE_HOME
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ CMD ["/entrypoint.py", "-fg"]
|
|||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends fontconfig python3 python3-jinja2 \
|
&& apt-get install -y --no-install-recommends fontconfig python3 python3-jinja2 \
|
||||||
&& apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
&& apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ARG TINI_VERSION=v0.18.0
|
ARG TINI_VERSION=v0.18.0
|
||||||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini
|
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /sbin/tini
|
||||||
@ -34,18 +34,20 @@ RUN groupadd --gid ${RUN_GID} ${RUN_GROUP} \
|
|||||||
&& useradd --uid ${RUN_UID} --gid ${RUN_GID} --home-dir ${CONFLUENCE_HOME} --shell /bin/bash ${RUN_USER} \
|
&& useradd --uid ${RUN_UID} --gid ${RUN_GID} --home-dir ${CONFLUENCE_HOME} --shell /bin/bash ${RUN_USER} \
|
||||||
&& echo PATH=$PATH > /etc/environment \
|
&& echo PATH=$PATH > /etc/environment \
|
||||||
\
|
\
|
||||||
&& mkdir -p ${CONFLUENCE_INSTALL_DIR} \
|
&& mkdir -p ${CONFLUENCE_INSTALL_DIR} \
|
||||||
&& curl -L --silent ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${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}/ \
|
&& chmod -R "u=rwX,g=rX,o=rX" ${CONFLUENCE_INSTALL_DIR}/ \
|
||||||
&& chown -R root. ${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}/logs \
|
||||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/temp \
|
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/temp \
|
||||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/work \
|
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/work \
|
||||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_HOME} \
|
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_HOME} \
|
||||||
\
|
\
|
||||||
&& 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/-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
|
||||||
|
|
||||||
VOLUME ["${CONFLUENCE_HOME}"] # Must be declared after setting perms
|
VOLUME ["${CONFLUENCE_HOME}"] # Must be declared after setting perms
|
||||||
|
|
||||||
COPY entrypoint.py /entrypoint.py
|
COPY entrypoint.py \
|
||||||
COPY config/* /opt/atlassian/etc/
|
shared-components/image/entrypoint_helpers.py /
|
||||||
|
COPY shared-components/support /opt/atlassian/support
|
||||||
|
COPY config/* /opt/atlassian/etc/
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
FROM adoptopenjdk/openjdk8:alpine
|
FROM adoptopenjdk/openjdk8:alpine
|
||||||
|
|
||||||
ENV RUN_USER confluence
|
ENV RUN_USER confluence
|
||||||
ENV RUN_GROUP confluence
|
ENV RUN_GROUP confluence
|
||||||
ENV RUN_UID 2002
|
ENV RUN_UID 2002
|
||||||
ENV RUN_GID 2002
|
ENV RUN_GID 2002
|
||||||
|
|
||||||
# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html
|
# https://confluence.atlassian.com/doc/confluence-home-and-other-important-directories-590259707.html
|
||||||
ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence
|
ENV CONFLUENCE_HOME /var/atlassian/application-data/confluence
|
||||||
ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence
|
ENV CONFLUENCE_INSTALL_DIR /opt/atlassian/confluence
|
||||||
|
|
||||||
WORKDIR $CONFLUENCE_HOME
|
WORKDIR $CONFLUENCE_HOME
|
||||||
|
|
||||||
@ -32,18 +32,20 @@ ARG DOWNLOAD_URL=https://product-downloads.atlassian.com/software/confluence/dow
|
|||||||
RUN addgroup -g ${RUN_GID} ${RUN_GROUP} \
|
RUN addgroup -g ${RUN_GID} ${RUN_GROUP} \
|
||||||
&& adduser -u ${RUN_UID} -G ${RUN_GROUP} -h ${CONFLUENCE_HOME} -s /bin/bash -D ${RUN_USER} \
|
&& adduser -u ${RUN_UID} -G ${RUN_GROUP} -h ${CONFLUENCE_HOME} -s /bin/bash -D ${RUN_USER} \
|
||||||
\
|
\
|
||||||
&& mkdir -p ${CONFLUENCE_INSTALL_DIR} \
|
&& mkdir -p ${CONFLUENCE_INSTALL_DIR} \
|
||||||
&& curl -L --silent ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "${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}/ \
|
&& chmod -R "u=rwX,g=rX,o=rX" ${CONFLUENCE_INSTALL_DIR}/ \
|
||||||
&& chown -R root. ${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}/logs \
|
||||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/temp \
|
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/temp \
|
||||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/work \
|
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_INSTALL_DIR}/work \
|
||||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_HOME} \
|
&& chown -R ${RUN_USER}:${RUN_GROUP} ${CONFLUENCE_HOME} \
|
||||||
\
|
\
|
||||||
&& 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/-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
|
||||||
|
|
||||||
VOLUME ["${CONFLUENCE_HOME}"] # Must be declared after setting perms
|
VOLUME ["${CONFLUENCE_HOME}"] # Must be declared after setting perms
|
||||||
|
|
||||||
COPY entrypoint.py /entrypoint.py
|
COPY entrypoint.py \
|
||||||
COPY config/* /opt/atlassian/etc/
|
shared-components/image/entrypoint_helpers.py /
|
||||||
|
COPY shared-components/support /opt/atlassian/support
|
||||||
|
COPY config/* /opt/atlassian/etc/
|
||||||
|
@ -1,89 +1,19 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys
|
from entrypoint_helpers import env, gen_cfg, str2bool, start_app
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import logging
|
|
||||||
import jinja2 as j2
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
RUN_USER = env['run_user']
|
||||||
# Utils
|
RUN_GROUP = env['run_group']
|
||||||
|
CONFLUENCE_INSTALL_DIR = env['confluence_install_dir']
|
||||||
|
CONFLUENCE_HOME = env['confluence_home']
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
gen_cfg('server.xml.j2', f'{CONFLUENCE_INSTALL_DIR}/conf/server.xml')
|
||||||
|
gen_cfg('seraph-config.xml.j2',
|
||||||
|
f'{CONFLUENCE_INSTALL_DIR}/confluence/WEB-INF/classes/seraph-config.xml')
|
||||||
|
gen_cfg('confluence-init.properties.j2',
|
||||||
|
f'{CONFLUENCE_INSTALL_DIR}/confluence/WEB-INF/classes/confluence-init.properties')
|
||||||
|
gen_cfg('confluence.cfg.xml.j2', f'{CONFLUENCE_HOME}/confluence.cfg.xml',
|
||||||
|
user=RUN_USER, group=RUN_GROUP, overwrite=False)
|
||||||
|
|
||||||
def set_perms(path, user, group, mode):
|
start_app(f'{CONFLUENCE_INSTALL_DIR}/bin/start-confluence.sh -fg', CONFLUENCE_HOME, name='Confluence')
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
|
||||||
shutil.chown(dirpath, user=user, group=group)
|
|
||||||
os.chmod(dirpath, mode)
|
|
||||||
for filename in filenames:
|
|
||||||
shutil.chown(os.path.join(dirpath, filename), user=user, group=group)
|
|
||||||
os.chmod(os.path.join(dirpath, filename), mode)
|
|
||||||
|
|
||||||
# Setup Jinja2 for templating
|
|
||||||
jenv = j2.Environment(
|
|
||||||
loader=j2.FileSystemLoader('/opt/atlassian/etc/'),
|
|
||||||
autoescape=j2.select_autoescape(['xml']))
|
|
||||||
|
|
||||||
def gen_cfg(tmpl, target, env, user='root', group='root', mode=0o644, overwrite=True):
|
|
||||||
if not overwrite and os.path.exists(target):
|
|
||||||
logging.info(f"{target} exists; skipping.")
|
|
||||||
return
|
|
||||||
|
|
||||||
logging.info(f"Generating {target} from template {tmpl}")
|
|
||||||
cfg = jenv.get_template(tmpl).render(env)
|
|
||||||
with open(target, 'w') as fd:
|
|
||||||
fd.write(cfg)
|
|
||||||
set_perms(target, user, group, mode)
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
# Setup inputs and outputs
|
|
||||||
|
|
||||||
# Import all ATL_* and Dockerfile environment variables. We lower-case
|
|
||||||
# these for compatability with Ansible template convention. We also
|
|
||||||
# support CATALINA variables from older versions of the Docker images
|
|
||||||
# for backwards compatability, if the new version is not set.
|
|
||||||
env = {k.lower(): v
|
|
||||||
for k, v in os.environ.items()
|
|
||||||
if k.startswith(('ATL_', 'CONFLUENCE_', 'RUN_', 'CATALINA_'))}
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
# Generate all configuration files for Confluence
|
|
||||||
|
|
||||||
if os.getuid() == 0:
|
|
||||||
gen_cfg('server.xml.j2',
|
|
||||||
f"{env['confluence_install_dir']}/conf/server.xml", env)
|
|
||||||
|
|
||||||
gen_cfg('seraph-config.xml.j2',
|
|
||||||
f"{env['confluence_install_dir']}/confluence/WEB-INF/classes/seraph-config.xml", env)
|
|
||||||
|
|
||||||
gen_cfg('confluence-init.properties.j2',
|
|
||||||
f"{env['confluence_install_dir']}/confluence/WEB-INF/classes/confluence-init.properties", env)
|
|
||||||
else:
|
|
||||||
logging.warning("Container not started as root. Tomcat, seraph-config.xml, confluence-init.properties boostrapping will be skipped.")
|
|
||||||
|
|
||||||
gen_cfg('confluence.cfg.xml.j2',
|
|
||||||
f"{env['confluence_home']}/confluence.cfg.xml", env,
|
|
||||||
user=env['run_user'], group=env['run_group'], mode=0o640,
|
|
||||||
overwrite=False)
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
# Start Confluence as the correct user
|
|
||||||
|
|
||||||
start_cmd = f"{env['confluence_install_dir']}/bin/start-confluence.sh"
|
|
||||||
if os.getuid() == 0:
|
|
||||||
logging.info(f"User is currently root. Will change directory ownership to {env['run_user']} then downgrade permissions")
|
|
||||||
set_perms(env['confluence_home'], env['run_user'], env['run_group'], 0o700)
|
|
||||||
|
|
||||||
cmd = '/bin/su'
|
|
||||||
start_cmd = ' '.join([start_cmd] + sys.argv[1:])
|
|
||||||
args = [cmd, env['run_user'], '-c', start_cmd]
|
|
||||||
else:
|
|
||||||
cmd = start_cmd
|
|
||||||
args = [start_cmd] + sys.argv[1:]
|
|
||||||
|
|
||||||
logging.info(f"Running Confluence with command '{cmd}', arguments {args}")
|
|
||||||
os.execv(cmd, args)
|
|
||||||
|
1
shared-components
Submodule
1
shared-components
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 30c9a5a1ca25ad8fcd3057481694b335fbf92370
|
Loading…
Reference in New Issue
Block a user