From 4f9f613b4ef50504576c9422009e947eeb523e6d Mon Sep 17 00:00:00 2001
From: Shane <shane@axiomdatascience.com>
Date: Fri, 11 Mar 2016 10:53:40 +0800
Subject: [PATCH] Add arbitrary filesystem resource overlays in build

---
 resources/overlays/README.txt |   14 ++++++++++++++
 Dockerfile                    |    6 ++++++
 .gitignore                    |   11 +++++++----
 README.md                     |   11 +++++++++++
 4 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index f9c80f1..245321d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,8 @@
-resources/geoserver.zip
-resources/plugins/*.zip
-resources/*jdk-*-linux-x64.tar.gz
-resources/jce_policy.zip
+resources/*
+!resources/plugins/
+resources/plugins/*
+!resources/plugins/README.txt
+!resources/overlays/
+resources/overlays/*
+!resources/overlays/README.txt
 .idea
diff --git a/Dockerfile b/Dockerfile
index edf49bc..b076dd2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -77,5 +77,11 @@
       done; \
     fi
 
+# Overlay files and directories in resources/overlays if they exist
+RUN rm /tmp/resources/overlays/README.txt && \
+    if ls /tmp/resources/overlays/* > /dev/null 2>&1; then \
+      cp -rf /tmp/resources/overlays/* /; \
+    fi;
+
 # Delete resources after installation
 RUN rm -rf /tmp/resources
diff --git a/README.md b/README.md
index 360517a..d2be021 100644
--- a/README.md
+++ b/README.md
@@ -63,6 +63,17 @@
 `resources/plugins` before building. You should also download the matching version
 GeoServer WAR zip file to `resources/geoserver.zip`.
 
+### Building with file system overlays (advanced)
+
+The contents of `resources/overlays` will be copied to the image file system
+during the build. For example, to include a static Tomcat `setenv.sh`,
+create the file at `resources/overlays/usr/local/tomcat/bin/setenv.sh`.
+
+You can use this functionality to write a static GeoServer directory to
+`/opt/geoserver/data_dir`, include additional jar files, and more.
+
+Overlay files will overwrite existing destination files, so be careful!
+
 ## Run
 
 You probably want to also have postgis running too. To create a running 
diff --git a/resources/overlays/README.txt b/resources/overlays/README.txt
new file mode 100644
index 0000000..4699e93
--- /dev/null
+++ b/resources/overlays/README.txt
@@ -0,0 +1,14 @@
+To include files in the container file system at arbitrary locations, build
+a directory structure from / here and include the files at the desired location.
+
+For example, to include a static Tomcat setenv.sh in the build, place it at:
+
+resources/overlays/usr/local/tomcat/bin/setenv.sh
+
+Other overlay examples include static GeoServer data directories, the Marlin renderer, etc.
+
+Note that overlay files will overwrite existing destination files, and that
+files in the overlay root will be copied to the container root
+(e.g. resources/overlay/somefile.txt will be copied to /somefile.txt).
+
+Be careful!

--
Gitblit v0.0.0-SNAPSHOT