susom/vertx-template

Name: vertx-template

Owner: Stanford School of Medicine

Description: Sample Vert.x web application with a relational database

Created: 2016-05-06 20:34:12.0

Updated: 2017-10-30 03:02:59.0

Pushed: 2017-10-02 21:56:05.0

Homepage:

Size: 83

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Template Web Application

Build Status Dependency Status

An opinionated way to build APIs and API-based web applications with a relational database as the primary data store.

Goals
Getting Started
What You Need

Java 8 and Maven 3.

Run Locally

Recommended steps for development:

The above steps should allow you to modify the HTML on the fly, and even some of the server code (the IntelliJ debugger reloads code on the fly for at least some cases).

To adjust your configuration, copy the sample properties file rather than modifying it, so you won't accidentally commit your local changes. The default configuration uses an embedded HSQLDB database. You will need to adjust your local properties if you use a different database.

ample.properties local.properties
Maven Instructions

Build everything, create the database schema, and start the server.

-DskipTests clean package
 -jar target/vertx-*-SNAPSHOT.jar create-database
 -jar target/vertx-*-SNAPSHOT.jar run

If you want to wipe out the embedded database, just delete the data files.

rf .hsql

You can combine the above to quickly reset and restart everything.

rf .hsql ; mvn -DskipTests clean package ; java -jar target/vertx-*-SNAPSHOT.jar create-database run

Before you commit your changes, run the static analysis checks. This will make sure code is formatted correctly and doesn't contain certain kinds of errors and security vulnerabilities. These are divided into two sets, only because certain of the tools are mutually incompatible.

-DskipTests -Dcheck1 clean verify
-DskipTests -Dcheck2 clean verify
Using PostgreSQL or Oracle

Since the application is built as a standard, executable .jar file, using a “real” database requires bundling the appropriate JDBC driver along with the application. To do this, just make sure you run the Maven build with the appropriate profile. For example:

-DskipTests -Ppostgres clean package

or:

-DskipTests -Poracle clean package

If you want a binary that can be used with either database you can include both:

-DskipTests -Ppostgres,oracle clean package
Run Docker Locally

To do this you should first install Docker for Mac (or Docker for Windows as the case may be).

Build the Maven artifacts and use it to create a docker image.

-DskipTests -Ppostgres,release clean package
p target/deploy.zip -d target/deploy
er build --pull -t app target/deploy

Spin up the PostgreSQL database.

er volume create --name postgres-data
er run -d --name postgres -p 5432:5432 \
   -v postgres-data:/var/lib/postgresql/data \
   -e "POSTGRES_PASSWORD=secret" postgres

Spin up the application, linking to the database container.

er volume create --name app-conf
er volume create --name app-logs
er run -it -v app-conf:/app/conf --name app \
   --link postgres:postgres app sh
 conf/app.properties
# Add this property to make it use fake authentication
insecure.fake.security=yes
Create the database schema
va -Dlog4j.configuration=file:log4j.xml -jar app.jar create-database
Make sure there weren't any errors
t logs/app.log
it
er rm app
er run -d -p 8080:8080/tcp -v app-conf:/app/conf -v app-logs:/app/logs \
   --link postgres:postgres --name app app

If you want to watch the logs:

er exec -it app tail -f logs/app.log

Now open the application in your browser.

http://localhost:8080/secure-app


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.