diff --git a/package/docker/Dockerfile b/package/docker/Dockerfile index 9a1b13e3d9..54457bc5ae 100644 --- a/package/docker/Dockerfile +++ b/package/docker/Dockerfile @@ -1,5 +1,5 @@ FROM tomcat:8.5-jdk8 -LABEL MAINTAINERS="Markus Döring , Matthew Blissett " +LABEL MAINTAINERS="Matthew Blissett " ARG IPT_VERSION ARG IPT_NAME=ROOT diff --git a/package/docker/README.adoc b/package/docker/README.adoc index eabcd92cdb..50ba32b5b8 100644 --- a/package/docker/README.adoc +++ b/package/docker/README.adoc @@ -8,7 +8,7 @@ We regularly publish IPT releases as Docker images to https://hub.docker.com/r/g == To run the Docker image -Refer to https://ipt.gbif.org/manual/en/ipt/2.5/installation/#_installation_using_docker[Installation using Docker] in the IPT User Manual. +Refer to https://ipt.gbif.org/manual/en/ipt/2.5/installation#installation-using-docker[Installation using Docker] in the IPT User Manual. == Upgrading @@ -18,10 +18,10 @@ Note that, for better consistency with the https://en.wikipedia.org/wiki/Filesys (This process is for GBIF developers.) -. `docker build --pull --build-arg IPT_VERSION=2.4.2 -t gbif/ipt:2.4.2 .` +. `docker build --pull --build-arg IPT_VERSION=2.5.0 -t gbif/ipt:2.5.0 .` . *Test the resulting image!* + -`docker run --volume /full/path/to/data-directory:/srv/ipt --publish 8080:8080 gbif/ipt:2.4.2` +`docker run --volume /full/path/to/data-directory:/srv/ipt --publish 8080:8080 gbif/ipt:2.5.0` -. `docker push gbif/ipt:2.4.2` (stop here for a pre-release) -. `docker tag gbif/ipt:2.4.2 gbif/ipt:latest && docker push gbif/ipt:latest` +. `docker push gbif/ipt:2.5.0` (stop here for a pre-release) +. `docker tag gbif/ipt:2.5.0 gbif/ipt:latest && docker push gbif/ipt:latest` diff --git a/src/main/java/org/gbif/ipt/config/AppConfig.java b/src/main/java/org/gbif/ipt/config/AppConfig.java index 5be352efb4..12fe914537 100644 --- a/src/main/java/org/gbif/ipt/config/AppConfig.java +++ b/src/main/java/org/gbif/ipt/config/AppConfig.java @@ -371,7 +371,7 @@ protected void loadConfig() throws InvalidConfigException { props.load(configStream); LOG.debug("Loaded default configuration from application.properties in classpath"); } - if (dataDir.dataDir != null && dataDir.dataDir.exists()) { + if (dataDir.isConfigured()) { // load user configuration properties from data dir ipt.properties (if it exists) File userCfgFile = new File(dataDir.dataDir, "config/" + DATADIR_PROPFILE); if (userCfgFile.exists()) { diff --git a/src/main/java/org/gbif/ipt/config/DataDir.java b/src/main/java/org/gbif/ipt/config/DataDir.java index daf10c1f88..bbdf3147df 100644 --- a/src/main/java/org/gbif/ipt/config/DataDir.java +++ b/src/main/java/org/gbif/ipt/config/DataDir.java @@ -164,7 +164,14 @@ public File dataFile(String path) { * @return true if a working data directory is configured */ public boolean isConfigured() { - return dataDir != null && dataDir.exists(); + return dataDir != null && dataDir.isDirectory() && dataDir.list().length > 0; + } + + /** + * @return true if a working data directory is configured, but is not yet set up + */ + public boolean isConfiguredButEmpty() { + return dataDir != null && dataDir.isDirectory() && dataDir.list().length == 0; } /** @@ -327,7 +334,7 @@ public boolean setDataDir(File dataDir) throws InvalidConfigException { throw new InvalidConfigException(TYPE.INVALID_DATA_DIR, "DataDir " + dataDir.getAbsolutePath() + " exists already and is no IPT data dir."); } - LOG.info("Reusing existing data dir."); + LOG.info("Reusing existing data dir {}", dataDir); // persist location in WEB-INF try { persistLocation(); @@ -343,6 +350,7 @@ public boolean setDataDir(File dataDir) throws InvalidConfigException { } else { // NEW datadir + LOG.info("Setting up new data directory {}", dataDir); try { // create new main data dir. Populate later FileUtils.forceMkdir(dataDir); @@ -353,8 +361,10 @@ public boolean setDataDir(File dataDir) throws InvalidConfigException { testFile.delete(); // create new default data dir createDefaultDir(); - // all works fine - persist location in WEB-INF - persistLocation(); + if (dataDirSettingFile != null) { + // all works fine - persist location in WEB-INF if that is how it is recorded + persistLocation(); + } return true; } catch (IOException e) { LOG.error("New DataDir " + dataDir.getAbsolutePath() + " not writable", e); diff --git a/src/main/java/org/gbif/ipt/config/SetupAction.java b/src/main/java/org/gbif/ipt/config/SetupAction.java index 9354299379..ce7a82be37 100644 --- a/src/main/java/org/gbif/ipt/config/SetupAction.java +++ b/src/main/java/org/gbif/ipt/config/SetupAction.java @@ -174,14 +174,19 @@ public void setSetup2(boolean setup2) { */ public String setup() { if (isHttpPost() && dataDirPath != null) { - // since IPT v2.2, user must check that they have read and understood disclaimer if (!readDisclaimer) { addFieldError("readDisclaimer", getText("admin.config.setup.read.error")); return INPUT; } + } + + if ((dataDir.dataDir != null && (!dataDir.dataDir.exists() || dataDir.isConfiguredButEmpty())) || + isHttpPost() && dataDirPath != null) { - File dd = new File(dataDirPath.trim()); + LOG.info("Set up data directory {}", dataDir.dataDir); + + File dd = dataDirPath != null ? new File(dataDirPath.trim()) : dataDir.dataDir; try { if (dd.isAbsolute()) { boolean created = configManager.setDataDir(dd); @@ -206,8 +211,10 @@ public String setup() { addActionError(msg); } } + if (dataDir.isConfigured()) { // the data dir is already/now configured, skip the first setup step + LOG.info("Skipping setup step 1"); return SUCCESS; } return INPUT;