From d452d48bef5973431cba5677a2a4706c22c16122 Mon Sep 17 00:00:00 2001
From: zwindler <dt.germain@gmail.com>
Date: Wed, 18 Jan 2017 15:19:37 +0100
Subject: [PATCH] RUN chown -R tomcat8:tomcat8 /var/lib/tomcat8 directive is
 extremely costly, adding a layers "changing" only the owner 230MB of data,
 thus adding 230 MB needlesly

Removing a few layers to correct this

Gained
---
 xwiki-mysql-tomcat/Dockerfile | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/xwiki-mysql-tomcat/Dockerfile b/xwiki-mysql-tomcat/Dockerfile
index e82826b..d40cff5 100644
--- a/xwiki-mysql-tomcat/Dockerfile
+++ b/xwiki-mysql-tomcat/Dockerfile
@@ -36,9 +36,14 @@ RUN echo "deb http://http.debian.net/debian jessie-backports main" > /etc/apt/so
   rm -rf /var/lib/apt/lists/*
 
 # Install XWiki as the ROOT webapp context in Tomcat
+# Create the Tomcat temporary directory
+# Configure the XWiki permanent directory
 RUN rm -rf /var/lib/tomcat8/webapps/* && \
+  mkdir -p /var/lib/tomcat8/temp && \
+  mkdir -p /var/lib/xwiki && \
   curl -L "http://download.forge.ow2.org/xwiki/xwiki-enterprise-web-${XWIKI_VERSION}.war" -o xwiki.war && \ 
   unzip -d /var/lib/tomcat8/webapps/ROOT xwiki.war && \
+  chown -R tomcat8:tomcat8 /var/lib/tomcat8 /var/lib/xwiki && \
   rm -f xwiki.war
 
 # Download the MySQL JDBC driver and install it in the XWiki webapp
@@ -52,24 +57,14 @@ RUN curl -L https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java
 # Configure Tomcat. For example set the memory for the Tomcat JVM since the default value is too small for XWiki
 COPY tomcat/setenv.sh /usr/share/tomcat8/bin/
 
-# Create the Tomcat temporary directory
-RUN mkdir -p /var/lib/tomcat8/temp
-
 # Setup the XWiki Hibernate configuration
 COPY xwiki/hibernate.cfg.xml /var/lib/tomcat8/webapps/ROOT/WEB-INF/hibernate.cfg.xml
 
-# Configure the XWiki permanent directory
-RUN mkdir -p /var/lib/xwiki
-
 # Set a specific distribution id in XWiki for this docker packaging.
 RUN sed "s/<id>org.xwiki.enterprise:xwiki-enterprise-web/<id>org.xwiki.enterprise:xwiki-enterprise-docker/" \
     < /var/lib/tomcat8/webapps/ROOT/META-INF/extension.xed > /var/lib/tomcat8/webapps/ROOT/META-INF/extension2.xed && \
   mv /var/lib/tomcat8/webapps/ROOT/META-INF/extension2.xed /var/lib/tomcat8/webapps/ROOT/META-INF/extension.xed
 
-# Set ownership and permission to the tomcat8 user
-RUN chown -R tomcat8:tomcat8 /var/lib/xwiki
-RUN chown -R tomcat8:tomcat8 /var/lib/tomcat8
-
 # Add scripts required to make changes to XWiki configuration files at execution time
 COPY xwiki/xwiki-config-replace.sh /usr/local/bin/xwiki-config-replace.sh
 COPY xwiki/xwiki-set-cfg /usr/local/bin/xwiki-set-cfg
-- 
GitLab