mirror of
https://github.com/Alfresco/acs-community-packaging.git
synced 2026-09-16 18:13:21 +00:00
REPO-4200: MNT-20344: No Alfresco-supplied docker images should run as root
- configured to run as non root user - changed internal ports - removed unused port
This commit is contained in:
+48
-15
@@ -2,6 +2,15 @@
|
||||
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
|
||||
FROM alfresco/alfresco-base-tomcat:8.5.34-java-11-openjdk-centos-7
|
||||
|
||||
# Set default user information
|
||||
ARG GROUPNAME=Alfresco
|
||||
ARG GROUPID=1000
|
||||
ARG USERNAME=alfresco
|
||||
ARG USERID=33000
|
||||
|
||||
# Set default environment args
|
||||
ARG TOMCAT_DIR=/usr/local/tomcat
|
||||
|
||||
# Base ACS Repository Image includes transformation commands:
|
||||
# /usr/bin/alfresco-pdf-renderer - alfresco-pdf-renderer
|
||||
# /usr/bin/convert - imagemagick
|
||||
@@ -47,17 +56,17 @@ RUN yum install wget -y && \
|
||||
yum remove wget -y
|
||||
|
||||
# Create prerequisite to store tools and properties
|
||||
RUN mkdir -p /usr/local/tomcat/shared/classes/alfresco/extension && \
|
||||
mkdir /usr/local/tomcat/alfresco-mmt
|
||||
RUN touch /usr/local/tomcat/shared/classes/alfresco-global.properties
|
||||
RUN mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension && \
|
||||
mkdir ${TOMCAT_DIR}/alfresco-mmt
|
||||
RUN touch ${TOMCAT_DIR}/shared/classes/alfresco-global.properties
|
||||
|
||||
# You need to run `mvn clean install` in the root of this project to update the following dependencies
|
||||
# Copy the WAR files to the appropriate location for your application server
|
||||
# Copy the JDBC drivers for the database you are using to the lib/ directory.
|
||||
# Copy the alfresco-mmt.jar
|
||||
COPY target/war /usr/local/tomcat/webapps
|
||||
COPY target/connector/* /usr/local/tomcat/lib/
|
||||
COPY target/alfresco-mmt/* /usr/local/tomcat/alfresco-mmt/
|
||||
COPY target/war ${TOMCAT_DIR}/webapps
|
||||
COPY target/connector/* ${TOMCAT_DIR}/lib/
|
||||
COPY target/alfresco-mmt/* ${TOMCAT_DIR}/alfresco-mmt/
|
||||
|
||||
# Copy Licenses to the root of the Docker image
|
||||
RUN mkdir /licenses
|
||||
@@ -65,7 +74,7 @@ COPY target/licenses/ /licenses/
|
||||
|
||||
# Change the value of the shared.loader= property to the following:
|
||||
# shared.loader=${catalina.base}/shared/classes
|
||||
RUN sed -i "s/shared.loader=/shared.loader=\${catalina.base}\/shared\/classes/" /usr/local/tomcat/conf/catalina.properties
|
||||
RUN sed -i "s/shared.loader=/shared.loader=\${catalina.base}\/shared\/classes/" ${TOMCAT_DIR}/conf/catalina.properties
|
||||
|
||||
# Add here configurations for alfresco-global.properties
|
||||
RUN echo -e '\n\
|
||||
@@ -80,30 +89,30 @@ img.root=/usr/lib64/ImageMagick-7.0.7\n\
|
||||
img.coders=/usr/lib64/ImageMagick-7.0.7/modules-Q16HDRI/coders\n\
|
||||
img.config=/usr/lib64/ImageMagick-7.0.7/config-Q16HDRI\n\
|
||||
img.exe=/usr/bin/convert\n\
|
||||
' >> /usr/local/tomcat/shared/classes/alfresco-global.properties
|
||||
' >> ${TOMCAT_DIR}/shared/classes/alfresco-global.properties
|
||||
|
||||
# Add debug for testing
|
||||
# RUN echo -e '\n\
|
||||
# log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug\n\
|
||||
# ' >> /usr/local/tomcat/shared/classes/alfresco/extension/custom-log4j.properties
|
||||
# ' >> ${TOMCAT_DIR}/shared/classes/alfresco/extension/custom-log4j.properties
|
||||
|
||||
RUN mkdir -p /usr/local/tomcat/amps
|
||||
RUN mkdir -p ${TOMCAT_DIR}/amps
|
||||
|
||||
# Copy the amps from build context to the appropriate location for your application server
|
||||
COPY target/amps /usr/local/tomcat/amps
|
||||
COPY target/amps ${TOMCAT_DIR}/amps
|
||||
|
||||
# Install amps on alfresco.war
|
||||
RUN java -jar /usr/local/tomcat/alfresco-mmt/alfresco-mmt*.jar install \
|
||||
/usr/local/tomcat/amps /usr/local/tomcat/webapps/alfresco -directory -nobackup -force
|
||||
RUN java -jar ${TOMCAT_DIR}/alfresco-mmt/alfresco-mmt*.jar install \
|
||||
${TOMCAT_DIR}/amps ${TOMCAT_DIR}/webapps/alfresco -directory -nobackup -force
|
||||
|
||||
# Docker CMD from parent image starts the server
|
||||
|
||||
# Make webapps folder read-only.
|
||||
RUN chmod -R =r /usr/local/tomcat/webapps && \
|
||||
RUN chmod -R =r ${TOMCAT_DIR}/webapps && \
|
||||
# Add catalina.policy to ROOT.war and alfresco.war
|
||||
# Grant all security permissions to alfresco webapp because of numerous permissions required in order to work properly.
|
||||
# Grant only deployXmlPermission to ROOT webapp.
|
||||
sed -i -e "\$a\grant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/alfresco\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/ROOT\/-\" \{\n\ permission org.apache.catalina.security.DeployXmlPermission \"ROOT\";\n\};" /usr/local/tomcat/conf/catalina.policy
|
||||
sed -i -e "\$a\grant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/alfresco\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/ROOT\/-\" \{\n\ permission org.apache.catalina.security.DeployXmlPermission \"ROOT\";\n\};" ${TOMCAT_DIR}/conf/catalina.policy
|
||||
|
||||
# fontconfig is required by Activiti worflow diagram generator
|
||||
# installing pinned dependencies as well
|
||||
@@ -115,6 +124,30 @@ RUN yum install -y fontconfig-2.13.0-4.3.el7 \
|
||||
dejavu-sans-fonts-2.33-6.el7 && \
|
||||
yum clean all
|
||||
|
||||
# The standard configuration is to have all Tomcat files owned by root with group GROUPNAME and whilst owner has read/write privileges,
|
||||
# group only has restricted permissions and world has no permissions.
|
||||
RUN mkdir -p ${TOMCAT_DIR}/conf/Catalina/localhost && \
|
||||
mkdir -p ${TOMCAT_DIR}/alf_data && \
|
||||
groupadd -g ${GROUPID} ${GROUPNAME} && \
|
||||
useradd -u ${USERID} -G ${GROUPNAME} ${USERNAME} && \
|
||||
chgrp -R ${GROUPNAME} ${TOMCAT_DIR} && \
|
||||
chmod g+w ${TOMCAT_DIR}/logs && \
|
||||
chmod g+rx ${TOMCAT_DIR}/conf && \
|
||||
chmod -R g+r ${TOMCAT_DIR}/conf && \
|
||||
find ${TOMCAT_DIR}/webapps -type d -exec chmod 0750 {} \; && \
|
||||
find ${TOMCAT_DIR}/webapps -type f -exec chmod 0640 {} \; && \
|
||||
chmod -R g+r ${TOMCAT_DIR}/webapps && \
|
||||
chmod g+r ${TOMCAT_DIR}/conf/Catalina && \
|
||||
chmod g+rwx ${TOMCAT_DIR}/alf_data && \
|
||||
chmod g+rwx ${TOMCAT_DIR}/logs && \
|
||||
chmod g+rwx ${TOMCAT_DIR}/temp && \
|
||||
chmod g+rwx ${TOMCAT_DIR}/work && \
|
||||
|
||||
sed -i -e "s_log4j.appender.File.File\=alfresco.log_log4j.appender.File.File\=${TOMCAT_DIR}/logs\/alfresco.log_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j.properties
|
||||
|
||||
# To remote debug into this image add: EXPOSE 8000
|
||||
# Changes are also required to the docker-compose/docker-compose.yml file.
|
||||
# EXPOSE 8000
|
||||
|
||||
USER ${USERNAME}
|
||||
@@ -30,13 +30,14 @@ services:
|
||||
-Dshare.host=localhost
|
||||
-Daos.baseUrlOverwrite=http://localhost:8082/alfresco/aos
|
||||
-Dmessaging.broker.url=\"failover:(tcp://activemq:61616)?timeout=3000&jms.useCompression=true\"
|
||||
-Dimap.server.port=1143
|
||||
-Dftp.port=1221
|
||||
"
|
||||
ports:
|
||||
- 8082:8080
|
||||
- 8000:8000
|
||||
- 445:445
|
||||
- 143:143
|
||||
- "21:21"
|
||||
- 143:1143
|
||||
- "21:1221"
|
||||
- "30000-30099:30000-30099"
|
||||
|
||||
share:
|
||||
|
||||
Reference in New Issue
Block a user