This is example of running Undertow HTTP server with /user and /user/:id endpoints. It runs in it's own Docker container and reads user details from PostgreSQL database running in separate Docker container.
How to setup and execute example:
NOTE: Make sure you have Linux, Docker, docker-compose and Maven with Java 1.8 installed.
Build the project using command:
./build.sh
This will build the maven project, prepare database Docker image and call GraalVM's native-image command to produce native binary. Then, this native binary will be provided to create small Alpine-based Docker image.
Run using docker-compose:
docker-compose up
Access running HTTP server endpoints to get Json response:
or
Application starts in 1-3ms (on Core i7) and Docker statistics show memory usage of only 13.5MB on startup. Docker image size is 33.1MB.
Fetching the data from database is provided using fluent API of JOOQ and Elegant Object's SQL-speaking objects.
Custom dummy classes are provided in graal-native source folder since GraalVM will not compile the native image without them. All of them are for PostgreSQL driver dependency.
I had to implement really basic connection pooling from the scratch since none of the existing connection pooling libraries (HikariCP, C3P0, BoneCP or DBCP) work with native-image yet.