A template repository for backend Java REST API server with a database
Stack: Ratpack Server, Postgres DB, Gradle, Docker, Shell
For Windows, use gradlew.bat instead of ./gradlew
./gradlew --refresh-dependencies clean build -x test./gradlew clean test./gradlew dependencies --refresh-dependenciesThis will boot up the entire application along with DB by performing the following tasks in the given order:
- Build the source code
- Run unit tests
- Build backend-api docker image
- Build and start Postgres and Postgres Admin containers
- Start backend-api server container
Make sure you have DATA_DIR environment variable set. This directory will be used as a persistent
volume mount for Postgres DB.
./gradlew fireUpThis will start three containers on same virtual network. Postgres Admin console will be available on
http://localhost:5433 and REST API server will be available on http://localhost:5050
To inspect the network use the following command:
docker inspect <container-name> -f "{{json .NetworkSettings.Networks }}" | jq .Here, <container-name> can be one of the three, {backend-api, postgres-db, postgres-admin} and
jq is just used to format the json output.
./gradlew shutDown./gradlew buildDockerImage./gradlew runServer