Devs ~ running application - GeoscienceAustralia/egeodesy GitHub Wiki

Update

Now that we have the docker-compose build and deploy feature

Docker-compose approach introduced in https://github.com/GeoscienceAustralia/Geodesy-Web-Services/pull/356.

cd geodesy-web-services
nix-shell
mvn package
docker-compose up [-d] #to start the database and web server
# The optional -d argument starts the docker images in detached mode.  The data populated into the database will persist
# if you stop it with `docker-compose stop`.

# ----
# In another shell - run this the *first time (only)* to populate the database
# 
mvn install -DskipTests            # MAY BE NECESSARY and doesnt take long to run anyway
mvn verify -pl gws-system-test     # to populate database with test data

# If the tests fail and you just need the database populated, run
mvn verify -pl gws-system-test -Dtest=UploadSiteLogsSystemTest
# ----
# To redeploy geodesy-web-services.war:
mvn package -DskipTests && docker-compose build web && docker-compose up -d web

# ----
# Other commands
ctrl-c              # to shutdown docker - only necessary when NO -d arg is used
docker-compose stop # To stop the composed containers - use with -d arg.  Controlling
                    # the containers in this way allows the database to be preserved (including between
                    # server reboots).
docker-compose rm  # to delete the database and web server containers

What follows is the old manual method. Which will no longer work as the application structure has changed - geodesy-web-services is now a parent project to sub-projects that includes the geodesy-domain-model (called gws-core) and what was the web services called geodesy-web-services is now gws-webapp.

To run the below:

cd geodesy-web-services

And suffix the mvn commands with -pl gws-core

TLDR; Next time after all the below

  • You've followed the below and setup your tomcat instance. Now you just want to start it all
cd geodesy-domain-model
mvn docker:run
psql -p 5433 -h localhost -U geodesy geodesydb  # After a minute - verify postgresql has started
# mvn -Pliquibase liquibase:update - not necessary - tomcat will perform this
# ----
# In another terminal
cd /var/tomcat
sudo bin/startup.sh
less logs/catalina.out  # Verify it starts up correctly - geodesy-web-services and geoserver
# ----
# Back in original terminal
mvn verify -Psystem-test -Dskip.createDb=true  # to populate db
# Hit http://localhost:8080/geodesy-web-services/siteLogs and verify output

To setup local database

  • A local db is not necessary. See Run web app (with Dev db) below for a quick way to get results.

  • clone geodesy-domain-model, geodesy-web-services

  • cd geodesy-domain-model

  • mvn install -DskipTests

  • cd geodesy-web-services

  • Fix src/main/webapp/META-INF/context.xml/context.xml - something like (change the pw):

<?xml version="1.0" encoding="UTF-8"?>
<Context>
  <Resource
  auth="Container"
  type="javax.sql.DataSource"
  driverClassName="org.postgresql.Driver"
  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
  url="jdbc:postgresql://localhost:5433/geodesydb"
  description="Distribution Datasource"
  username="geodesy"
  password="secretpw"
  name="jdbc/GeodesyDB"
  maxActive="40"
  maxWait="10000"/>
</Context>
  • mvn install

Setup Tomcat

  • Install Tomcat manually OR
  • If using Geodesy-Nix, the configuration has tomcat.service commented out. Fix that and run nixos-rebuild switch
    • It installs to /var/tomcat

Install geodesy-web-services webapp

  • Copy target/geodes-web-services.war to tomcat webapps

Setup local geoserver

I HAVEN'T GOT THIS VERSION TO WORK YET (from https://github.com/GeoscienceAustralia/geodesy-web-services-aws). Instead find the geoserver.zip attached to the geodesy-devs slack channel and unzip in tomcat/webapps && copy the geodesy-web-services/META-INF/context.xml into geoserver/META-INF.

cd /var/tomcat/webapps
nix-env -iA nixos.awscli
aws --no-sign-request s3 cp s3://geodesy-web-services/geoserver/geoserver-2.9.1-war.zip .
aws --no-sign-request s3 cp s3://geodesy-web-services/geoserver/geoserver-2.9.1-app-schema-plugin.zip .
sudo unzip geoserver-2.9.1-war.zip geoserver.war -d .
# If tomcat has started, the war will be exploded.  If not run this first ...
sudo unzip geoserver.war -d geoserver
# Continue ...
sudo unzip -o geoserver-2.9.1-app-schema-plugin.zip *.jar -d geoserver/WEB-INF/lib
aws --no-sign-request s3 cp s3://geodesy-web-services/geoserver/web.xml .
# Before the following you may need to rename or remove any existing web.xml file
sudo mv web.xml ../conf
  • Lastly copy the geodesy-web-services/META-INF/context.xml into geoserver/META-INF.

Setup local dev database:

  • cd domain-model
  • mvn docker:build
  • mvn docker:stop
  • mvn docker:run
  • (one line) mvn docker:build && mvn docker:stop && mvn docker:run
    • Docker in this project runs a postgresql db on port :5433

Populate db

  • (Re-)Start tomcat so the geodesy-web-services starts correctly (JDBC connection can now be established)
  • cd geodesy-domain-model
  • mvn verify -Dsystem-test -Dskip.createDb=true # this -D only needed currently due to a bug

Install Node

  • node and its npm need to be installed. The simplest way when running under nixos or with nix installed is to start a shell (see the shell.nix file) with:
nix-shell

Initialise app

npm install

or

npm update

Run web app (with Local)

  • Working with the gnss-sitelog-manager project
  • Populate your tools/env/local.ts with
import {EnvConfig} from './env-config.interface';
const LocalConfig: EnvConfig = {
  ENV: 'LOCAL',
  WEB_SERVICE_URL: 'http://localhost:8080/geodesy-web-services',
  WFS_GEOSERVER_URL: 'http://localhost:8080/geoserver/wfs',
};
export = LocalConfig;

npm run serve.local

Run web app (with Dev db)

  • to avoid most of the above work, a database and geoserver are setup in AWS. The database will go down at any time though and hence my preference for running a local db.
  • simply:
npm start

Which effectively does:

npm run serve.dev

(see package.json for the steps behind the purposes of serve.dev etc).

⚠️ **GitHub.com Fallback** ⚠️