Skip to content

A simple implementation of a Jetty Web Server with Spark Java and GraalVm on Docker container

Notifications You must be signed in to change notification settings

AlessioCoser/graalvm_webserver

Repository files navigation

GraalVm WebServer with Spark Java on Docker

A simple implementation of a Jetty Web Server with Spark Java and GraalVm on Docker container:

  1. 🚀 blazingly fast (~4ms server startup)
  2. 🥬 very lightweight (~30MB Docker image)

Prerequisites

  • Java 11
  • Docker

Build

Build the application and the docker image

./gradlew clean build
docker build --build-arg VERSION=1.0 -t webserver:1.0 .

Run

Run the docker container

docker run --rm -p 4545:4545 -t webserver:1.0

Run the docker container pointing a specific postgresql database

docker run --rm \
    --env DB_HOST=database_host:5432 \
    --env DB_DATABASE=db_name \
    --env DB_USER=another_user \
    --env DB_PASSWORD=another_password \
    -p 4545:4545 -t webserver:1.0

Run the docker container on different port

docker run --rm --env PORT=4321 -p 4321:4321 -t webserver:1.0

Try it out

Home:

curl http://localhost:4545

Healthcheck:

curl http://localhost:4545/alive

Todo list:

curl http://localhost:4545/todos

About

A simple implementation of a Jetty Web Server with Spark Java and GraalVm on Docker container

Resources

Stars

Watchers

Forks

Packages

No packages published