diff --git a/CHANGELOG.md b/CHANGELOG.md index 29947b3..7b9c904 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/internetofwater/nldi-services/compare/1.12.4...master) +## [Unreleased](https://github.com/internetofwater/nldi-services/compare/1.12.5...master) +### Changed +* Switched to using actively maintained Docker images +* Simplified docker compose workflow + +## [1.12.5](https://github.com/internetofwater/nldi-services/compare/1.12.4...1.12.5) ### Fixed * Feature ID validation no longer fails in comid is null +### Changed +* Updated dependencies + ## [1.12.4](https://github.com/internetofwater/nldi-services/compare/1.12.3...1.12.4) ### Fixed * Proper CORS header is included in response diff --git a/Dockerfile b/Dockerfile index c36a2ae..8a6136c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM artifactory.wma.chs.usgs.gov/docker-official-mirror/maven:3.6.0-jdk-11 AS build +ARG DOCKER_MIRROR +FROM ${DOCKER_MIRROR}maven:3.8.1-jdk-11-slim AS build LABEL maintainer="gs-w_eto_eb_federal_employees@usgs.gov" # Add pom.xml and install dependencies @@ -10,7 +11,7 @@ RUN mvn -B dependency:go-offline COPY src /build/src RUN mvn -B clean package -Dmaven.test.skip=true -FROM artifactory.wma.chs.usgs.gov/docker-official-mirror/usgswma/openjdk:debian-stretch-openjdk-11.0.2-89c4dd2d55ba476c77aa8fd5274dcb8a1ef115b7 +FROM ${DOCKER_MIRROR}openjdk:11.0-jre-slim COPY --chown=1000:1000 --from=build /build/target/nldi-services-*.jar app.jar @@ -19,4 +20,5 @@ USER $USER CMD ["java", "-jar", "app.jar"] HEALTHCHECK --interval=30s --timeout=3s \ - CMD curl -H "Accept: application/json" -v -k "http://127.0.0.1:${SERVER_PORT}${SERVER_CONTEXT_PATH}/about/health" | grep -q "{\"status\":\"UP\"}" || exit 1 \ No newline at end of file + CMD curl -H "Accept: application/json" -v -k \ + "http://127.0.0.1:${SERVER_PORT}${SERVER_CONTEXT_PATH}/about/health" | grep -q "{\"status\":\"UP\"}" || exit 1 diff --git a/README.md b/README.md index b54b9d2..2e060c6 100755 --- a/README.md +++ b/README.md @@ -5,6 +5,19 @@ This repository houses code behind the Network Linked Data Index (NLDI) API [(Swagger Docs)](https://labs.waterdata.usgs.gov/api/nldi/swagger-ui/index.html). The NLDI is hosted as part of the [USGS Waterdata Labs](https://labs.waterdata.usgs.gov/index.html), a set of new capabilities being developed by the USGS Water Mission Area. +## Table of Contents +* [Public API](#public-api) + * [The root is {host}/api/nldi](#the-root-is-hostapinldi) + * [Up/Down Stream navigation](#updown-stream-navigation) + * [Up/Down Stream data](#updown-stream-data) + * [Query Parameters](#query-parameters) + * [Other Endpoints](#other-endpoints) +* [Development](#development) + * [Dependencies](#dependencies) + * [Docker Compose](#docker-compose) + * [Environment variables](#environment-variables) + * [Testing](#testing) + ## Public API The services are accessed via an http GET request. All output is generated as JSON and GeoJSON. @@ -56,13 +69,23 @@ Rather, start up the demo db and create an application.yml file as described bel This application utilizes a PostgreSQL database. [nldi-db](https://github.com/internetofwater/nldi-db) contains everything you need to set up a development database environment. It includes data for the Yahara River in Wisconsin. -### Running the Demo DB for local development -See the nldi-db project for more details, but in short: -```shell -docker network create --subnet=172.26.0.0/16 nldi -docker run -it --env-file ./.env -p 127.0.0.1:5437:5432/tcp ghcr.io/internetofwater/nldi-db:demo +### Docker Compose +This project includes a Docker-Compose file with all necessary variables predefined. +First, start the demo database by running: + +```sh +docker-compose up -d nldi-db ``` -Note the _5437_ port mapping, which is used in the environmental variables below. + +Then, build and start the NLDI services by running: + +```sh +docker-compose up nldi-services +``` + +These test services will be accessible at . \ +If you would like to build these images using a mirror url simply set a `DOCKER_MIRROR` environment variable or include +it as a build argument. ### Environment variables To run the project (connecting to a separately running db instance) you will need to create the file application.yml in the project's root directory and add the following (normal defaults are filled in): diff --git a/config.env b/config.env deleted file mode 100644 index 5ccd59e..0000000 --- a/config.env +++ /dev/null @@ -1,8 +0,0 @@ -serverContextPath=/nldi -serverPort=8080 - -nldiProtocol=http -nldiHost=localhost:8080 -nldiPath=nldi - -springFrameworkLogLevel=info diff --git a/docker-compose.yml b/docker-compose.yml index a89d87c..def4f14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,11 +3,46 @@ services: nldi-services: - build: . image: nldi-services + container_name: nldi-services + build: + context: . + args: + DOCKER_MIRROR: ${DOCKER_MIRROR} ports: - - "8082:8080" - - env_file: - - config.env - - secrets.env + - "8080:8080" + environment: + serverContextPath: /nldi + serverPort: 8080 + nldiProtocol: http + nldiHost: "localhost:8080" + nldiPath: /nldi + springFrameworkLogLevel: info + nldiDbHost: nldi-db + nldiDbPort: 5432 + nldiDbUsername: read_only_user + nldiDbPassword: changeMe + nldiDbName: nldi + pygeoapiUrl: "https://labs.waterdata.usgs.gov/api/nldi/pygeoapi/" + networks: + - nldi + nldi-db: + image: ghcr.io/internetofwater/nldi-db:demo + container_name: nldi-db-demo + environment: + POSTGRES_PASSWORD: changeMe + NLDI_DATABASE_ADDRESS: localhost + NLDI_DATABASE_NAME: nldi + NLDI_DB_OWNER_USERNAME: nldi + NLDI_DB_OWNER_PASSWORD: changeMe + NLDI_SCHEMA_OWNER_USERNAME: nldi_schema_owner + NLDI_SCHEMA_OWNER_PASSWORD: changeMe + NHDPLUS_SCHEMA_OWNER_USERNAME: nhdplus + NLDI_READ_ONLY_USERNAME: read_only_user + NLDI_READ_ONLY_PASSWORD: changeMe + DB_DEMO_PORT: 5432 + networks: + - nldi + + networks: + nldi: diff --git a/secrets.env.sample b/secrets.env.sample deleted file mode 100644 index 7bdc738..0000000 --- a/secrets.env.sample +++ /dev/null @@ -1,5 +0,0 @@ -nldiDbHost=hostNameOfDatabase -nldiDbPort=portNumberForDatabase -nldiDbUsername=dbUserName -nldiDbPassword=dbPassword -nldiDbName=dbName