diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 949b1dc9524e98a0a2a3226c49a4cac7a2037960..7fc13f023bd4bb0cf60913f5a7fd253204f0012f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -104,16 +104,31 @@ default: docker build \ ${BUILD_ARGS} \ --pull \ - --tag "${latest_image_name}" \ + --tag "${env_image_name}" \ --file "${CI_PROJECT_DIR}/${DOCKERFILE}" \ "${CI_PROJECT_DIR}/."; - - docker push "${latest_image_name}"; + - docker push "${env_image_name}"; - | - docker tag "${latest_image_name}" "${env_image_name}"; - docker push "${env_image_name}"; - - | - docker tag "${latest_image_name}" "${sha_image_name}"; + docker tag "${env_image_name}" "${sha_image_name}"; docker push "${sha_image_name}"; + - | + docker_latest_image="usgs/${CI_PROJECT_NAME}:latest"; + docker_env_image="usgs/${CI_PROJECT_NAME}:${ENVIRONMENT}-latest"; + + if [[ "${ENVIRONMENT}" != "development" ]]; then + docker tag "${env_image_name}" "${latest_image_name}"; + docker push "${latest_image_name}"; + fi + + if [[ "${PUSH_DOCKER}" == true ]]; then + docker tag "${env_image_name}" "${docker_env_image}"; + docker push "${docker_env_image}"; + + if [[ "${ENVIRONMENT}" != "development" ]]; then + docker tag "${env_image_name}" "${docker_latest_image}"; + docker push "${docker_latest_image}"; + fi + fi - | printf " -------- @@ -129,6 +144,7 @@ default: BUILD_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 FROM_IMAGE=${DEVOPS_REGISTRY}usgs/amazoncorretto:11 IMAGE_TAG: ${ENVIRONMENT}-${CI_COMMIT_SHORT_SHA} + PUSH_DOCKER: 'false' REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE} TAG: build @@ -169,6 +185,7 @@ CHS Registry: CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} CI_JOB_TOKEN=${CI_JOB_TOKEN} CI_PROJECT_URL=${CI_PROJECT_URL} + PUSH_DOCKER: 'true' UPSTREAM_PATH: ghsc/nshmp/nshmp-haz Container Registry: diff --git a/build.gradle b/build.gradle index 684942bb13d93b773bd75aa44f9fd91c2e874714..9dd53b0a2c46d6b2cec7cf056b61633a7f4f6eea 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ plugins { id "com.github.johnrengelman.shadow" version "${shadowVersion}" id "com.github.node-gradle.node" version "${nodePluginVersion}" id "com.github.spotbugs" version "${spotbugsVersion}" - id "com.palantir.git-version" version "${gitVersionVersion}" + id "com.palantir.git-version" version "${gitVersionVersion}" apply false id "com.star-zero.gradle.githook" version "${githooksVersion}" id "eclipse-wtp" id "io.micronaut.application" version "${micronautPluginVersion}" diff --git a/docs/pages/Building-&-Running.md b/docs/pages/Building-&-Running.md index 5bafde11cc8c16ef0717f387c459261dbce4512c..8464fb14d48b867f701a17c770c59e4294996aed 100644 --- a/docs/pages/Building-&-Running.md +++ b/docs/pages/Building-&-Running.md @@ -6,8 +6,7 @@ * [Developer Basics](./Developer-Basics.md#developer-basics) * [Calculation Configuration](./Calculation-Configuration.md#calculation-configuration) * [Site Specification](./Site-Specification.md#site-specification) - * [Examples](../../etc/examples) (or - [on GitLab](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/-/tree/main/etc/examples)) + * [Examples](../../etc/examples) * [Web Services](./Web-Services.md) ## Build & Run Options @@ -74,11 +73,11 @@ files. Disaggregations also have some independent ## Run with [Docker](https://docs.docker.com/install/) -nshmp-haz is available as a public image from the -[container registry](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/container_registry) +nshmp-haz is available as a public image from [Docker hub](https://hub.docker.com/r/usgs/nshmp-haz) with tags: * `latest`: Refers to the latest updates from the main or production branch +* `development-latest`: Refers to forks of the repository. * `staging-latest`: Latest updates associated with the [main](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/-/tree/main) branch * `production-latest`: Latest stable release associated with the @@ -109,13 +108,12 @@ to a minimum of 4 GB. The *nshmp-haz* application may be run as a Docker container which mitigates the need to install Git, Java, or other dependencies besides Docker. A public image is available -from this repository's -[container registry](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/container_registry). +from [Docker hub](https://hub.docker.com/r/usgs/nshmp-haz) which can be run with: ```bash # Pull docker image -docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz:latest +docker pull usgs/nshmp-haz:latest # Run docker image docker run \ @@ -125,7 +123,7 @@ docker run \ --volume /absolute/path/to/sites/file:/app/sites.<geojson | csv> \ --volume /absolute/path/to/config/file:/app/config.json \ --volume /absolute/path/to/output:/app/output \ - code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz-ws + usgs/nshmp-haz ``` Where: @@ -158,7 +156,7 @@ assumption a GeoJSON [site](./Site-Specification.md) file exists named `sites.ge git clone https://code.usgs.gov/ghsc/nshmp/nshms/nshm-hawaii.git # Pull image -docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz:latest +docker pull usgs/nshmp-haz:latest # Run nshmp-haz HazardCalc docker run \ @@ -166,7 +164,7 @@ docker run \ --volume "$(pwd)/nshm-hawaii:/app/model" \ --volume "$(pwd)/sites.geojson" \ --volume "$(pwd)/hawaii-hazard-output:/app/output" \ - code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz + usgs/nshmp-haz ``` #### [`DisaggCalc`](../../src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java) Example @@ -180,7 +178,7 @@ assumption a GeoJSON [site](./Site-Specification.md) file exists named `sites.ge git clone https://code.usgs.gov/ghsc/nshmp/nshms/nshm-hawaii.git # Pull image -docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz:latest +docker pull usgs/nshmp-haz:latest # Run nshmp-haz DisaggCalc docker run \ @@ -189,7 +187,7 @@ docker run \ --volume "$(pwd)/nshm-hawaii:/app/model" \ --volume "$(pwd)/sites.geojson" \ --volume "$(pwd)/hawaii-disagg-output:/app/output" \ - code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz:latest + usgs/nshmp-haz:latest ``` #### [`RateCalc`](../../src/main/java/gov/usgs/earthquake/nshmp/RateCalc.java) Example @@ -203,7 +201,7 @@ assumption a GeoJSON [site](./Site-Specification.md) file exists named `sites.ge git clone https://code.usgs.gov/ghsc/nshmp/nshms/nshm-hawaii.git # Pull image -docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz:latest +docker pull usgs/nshmp-haz:latest # Run nshmp-haz RateCalc docker run \ @@ -211,7 +209,7 @@ docker run \ --volume "$(pwd)/nshm-hawaii:/app/model" \ --volume "$(pwd)/sites.geojson" \ --volume "$(pwd)/hawaii-rate-output:/app/output" \ - code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz + usgs/nshmp-haz ``` ### Run Customization @@ -223,13 +221,13 @@ be set with the environment flag (-e, -env): docker run \ --env JAVA_MEMORY=<MEMORY> \ ... - code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz + usgs/nshmp-haz # Example docker run \ --env JAVA_MEMORY="12g" \ ... - code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz + usgs/nshmp-haz ``` Where: diff --git a/docs/pages/Model-Files.md b/docs/pages/Model-Files.md index 7f8290acad695abef477262a5ef579f9dda0f919..347935dd0c9ff96f8cd04cf9bde1a7bd746b3b48 100644 --- a/docs/pages/Model-Files.md +++ b/docs/pages/Model-Files.md @@ -80,7 +80,7 @@ or its children will be processed; any standalone sources will be ignored. For e **source-group.json:** A specialized form of logic tree that describes model branches that are additive and therefore does not include weights. Examples from the NSHM for the conterminous U.S. -NSHM include the Cascadia segmented partial-rupture models and the New Madrid 1500-yr cluster +NSHM include the Cascadia segmented and partial-rupture models, and the New Madrid 1500-yr cluster branches. The branch objects in a source group _may_ include an optional `scale` member that can be used to impose a probability of occurrence or other scaling requred by a NSHM. If absent, the `scale` value is one. diff --git a/docs/pages/Source-Types.md b/docs/pages/Source-Types.md index 90b24bbe9d474e8ba5798e49a92656fcce0d3fc5..76d90b847cbb4d1ab2e1444c3106429b7e12a4a6 100644 --- a/docs/pages/Source-Types.md +++ b/docs/pages/Source-Types.md @@ -71,6 +71,9 @@ rupture representations. ```json { "grid-spacing": 0.1, + "smoothing-density": 10, + "smoothing-limit": 40.0, + "opt-distance-bin": 1.0, "point-source-type": "FINITE", "rupture-scaling": "NSHM_POINT_WC94_LENGTH", "max-depth": 22.0, @@ -151,6 +154,9 @@ __zone-config.json:__ Zone source model configuration is identical to a grid sou ```json { "grid-spacing": 0.1, + "smoothing-density": 10, + "smoothing-limit": 40.0, + "opt-distance-bin": null, "point-source-type": "FIXED_STRIKE", "rupture-scaling": "NSHM_POINT_WC94_LENGTH", "max-depth": 22.0, diff --git a/docs/pages/Web-Services.md b/docs/pages/Web-Services.md index 3076ca1dbf115e770cb9ec0e4793b87533c32412..bbfa9ced8fc80eb4b00083aa0a9ef0c682bbe76b 100644 --- a/docs/pages/Web-Services.md +++ b/docs/pages/Web-Services.md @@ -119,12 +119,12 @@ Open browser to [http://localhost:8080/](http://localhost:8080/). ### Run from Container Registry -A public Docker image is avaialable from this repository's -[container registry](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/container_registry). +A public Docker image is avaialable from [Docker hub](https://hub.docker.com/r/usgs/nshmp-haz-ws). -There are 3 main tags: +There are 4 main tags: * `latest`: Refers to the latest updates from the main or production branch +* `development-latest`: Refers to forks of the repository. * `staging-latest`: Refers to the [main](https://code.usgs.gov/ghsc/nshmp/nshmp-haz/-/tree/main) branch and is the latest updates * `production-latest`: Refers to the @@ -132,10 +132,10 @@ There are 3 main tags: ```bash # Pull image -docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz-ws:latest +docker pull usgs/nshmp-haz-ws:latest # Run -docker run -p 8080:8080 -v "/path/to/model:/model" code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz-ws +docker run -p 8080:8080 -v "/path/to/model:/model" usgs/nshmp-haz-ws ``` Web service runs on [http://localhost:8080/](http://localhost:8080/) @@ -146,14 +146,14 @@ The hazard model is read in via Docker volumes. ```bash # Pull image -docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz-ws:latest +docker pull usgs/nshmp-haz-ws:latest # Download NSHM CONUS cd .. git clone https://code.usgs.gov/ghsc/nshmp/nshms/nshm-conus # Run web services -docker run -p 8080:8080 -v "$(pwd):/model" code.usgs.gov:5001/ghsc/nshmp/nshmp-haz/nshmp-haz-ws +docker run -p 8080:8080 -v "$(pwd):/model" usgs/nshmp-haz-ws ``` Open browser to [http://localhost:8080/](http://localhost:8080/). diff --git a/gradle.properties b/gradle.properties index d3bac3e39e1fe7efbc5750136b5f98df442e5e9a..5a1abcf15153010267df226113b2a6efc2785d27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ micronautRxVersion = 2.1.1 micronautPluginVersion = 3.1.1 nodePluginVersion = 3.0.1 nodeVersion = 16.3.0 -nshmpLibVersion = 1.0.6 +nshmpLibVersion = 1.1.0 nshmpWsUtilsVersion = 0.3.7 shadowVersion = 7.1.2 spotbugsVersion = 4.7.0 diff --git a/gradle/app-version.gradle b/gradle/app-version.gradle index 2367ef4006a7789f8bb00b7402d326522a5f04f9..c0f4c3c4c23fa00d78ca1a4d5d4af2e67101f91c 100644 --- a/gradle/app-version.gradle +++ b/gradle/app-version.gradle @@ -1,24 +1,29 @@ -apply plugin: "com.palantir.git-version" tasks.withType(JavaCompile) { doFirst { - def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-haz-version.json") - new File(versionFile.getParent()).mkdirs() - def details = versionDetails() - def ciProjectUrl = System.getenv("CI_PROJECT_URL") - def branch = System.getenv("CI_COMMIT_BRANCH") - def versionInfo = [ - branchName: branch ? branch : details.branchName, - commitDistance: details.commitDistance, - gitHash: details.gitHash, - gitHashFull: details.gitHashFull, - isCleanTag: details.isCleanTag, - lastTag: details.lastTag, - projectName: project.name, - url: ciProjectUrl ? ciProjectUrl : 'git config --get remote.origin.url'.execute().text.replace('\n', ''), - version: details.version, - ] - def json = groovy.json.JsonOutput.toJson(versionInfo) - versionFile.write(groovy.json.JsonOutput.prettyPrint(json)) + try { + apply plugin: "com.palantir.git-version" + + def versionFile = new File("${projectDir}/src/main/resources/version/nshmp-haz-version.json") + new File(versionFile.getParent()).mkdirs() + def details = versionDetails() + def ciProjectUrl = System.getenv("CI_PROJECT_URL") + def branch = System.getenv("CI_COMMIT_BRANCH") + def versionInfo = [ + branchName: branch ? branch : details.branchName, + commitDistance: details.commitDistance, + gitHash: details.gitHash, + gitHashFull: details.gitHashFull, + isCleanTag: details.isCleanTag, + lastTag: details.lastTag, + projectName: project.name, + url: ciProjectUrl ? ciProjectUrl : "git config --get remote.origin.url".execute().text.replace("\n", ""), + version: details.version, + ] + def json = groovy.json.JsonOutput.toJson(versionInfo) + versionFile.write(groovy.json.JsonOutput.prettyPrint(json)) + } catch (Exception e) { + println("Failed to create version file.") + } } }