{"id":21877633,"url":"https://github.com/rbiedrawa/spring-docker-gradle-setup","last_synced_at":"2026-04-05T20:36:53.005Z","repository":{"id":162193117,"uuid":"354297772","full_name":"rbiedrawa/spring-docker-gradle-setup","owner":"rbiedrawa","description":"This repository contains sample setup for building optimised docker image and shows some useful plugins and techniques.","archived":false,"fork":false,"pushed_at":"2022-01-31T02:03:56.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T23:43:26.519Z","etag":null,"topics":["cloud-native-buildpacks","distroless","docker","docker-compose","dockerfile","gradle","jib-gradle","multi-stage-build","non-root","optimised-images","production-grade-spring","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rbiedrawa.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-03T13:21:45.000Z","updated_at":"2021-12-27T12:22:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"bac41fb6-9857-48f3-b50d-849a5dab232b","html_url":"https://github.com/rbiedrawa/spring-docker-gradle-setup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rbiedrawa/spring-docker-gradle-setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbiedrawa%2Fspring-docker-gradle-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbiedrawa%2Fspring-docker-gradle-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbiedrawa%2Fspring-docker-gradle-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbiedrawa%2Fspring-docker-gradle-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbiedrawa","download_url":"https://codeload.github.com/rbiedrawa/spring-docker-gradle-setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbiedrawa%2Fspring-docker-gradle-setup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31449830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T15:22:31.103Z","status":"ssl_error","status_checked_at":"2026-04-05T15:22:00.205Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-native-buildpacks","distroless","docker","docker-compose","dockerfile","gradle","jib-gradle","multi-stage-build","non-root","optimised-images","production-grade-spring","spring-boot"],"created_at":"2024-11-28T08:09:49.702Z","updated_at":"2026-04-05T20:36:52.976Z","avatar_url":"https://github.com/rbiedrawa.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dockerize your Spring Boot application - Useful plugins and techniques to build efficient docker image\n\nThis repository contains sample setup for building optimised docker image and shows some useful plugins and techniques.\n\n## Features\n\n* Efficient docker image using **Layered Jars**.\n* **Multi-stage Docker** build.\n* **Google’s Distroless** base image with healthchecks without `bash` or `curl`\n* Configuring **Non-root user** in docker image.\n* **Cloud native buildpacks** - with spring boot gradle plugin.\n* **Jib** gradle plugin.\n* Using **docker-compose** with gradle.\n\n## Getting Started\n\n### Prerequisites\n\n* Java 11\n* Docker\n\n### Installation\n\n|Step| Custom Image | Cloud native Image| Jib Image |\n| -------------:|:--------:|:--------:|:--------:|\n| Build image | `docker build -t spring-docker-setup-healthcheck:0.0.1-SNAPSHOT .` |`./gradlew bootBuildImage` |`./gradlew jibDockerBuild` | \n| Start docker-compose |  `./gradlew healthcheckComposeUp` | `./gradlew bootAppComposeUp` |`./gradlew jibComposeUp` | \n| Stop docker-compose |  `./gradlew healthcheckComposeDown` | `./gradlew bootAppComposeDown` |`./gradlew jibComposeUp` |\n\n### Usage\n\n* After successful installation, check if all applications are running `docker ps` e.g.\n    ```shell\n      docker ps\n  \n      CONTAINER ID   IMAGE                                                         COMMAND                  CREATED              STATUS                        PORTS                     NAMES\n      2eab466c947d   spring-docker-setup-jib-plugin:0.0.1-SNAPSHOT                 \"java -cp /app/resou…\"   7 seconds ago        Up 7 seconds                  0.0.0.0:53637-\u003e8080/tcp   spring-docker-setup-jib\n      9cd791a65fef   spring-docker-setup-healthcheck:0.0.1-SNAPSHOT                \"java org.springfram…\"   About a minute ago   Up About a minute (healthy)   0.0.0.0:53551-\u003e8080/tcp   spring-docker-setup-healthcheck\n      0bfcde6a2f2e   com.rbiedrawa.docker.app/spring-docker-setup:0.0.1-SNAPSHOT   \"/cnb/process/web\"       2 minutes ago        Up 2 minutes                  0.0.0.0:8080-\u003e8080/tcp    spring-docker-setup\n    ```\n  **** Notice healthy status in our `custom` image.\n\n* Next investigate how spring packaged the jars.\n  ```shell\n   cd ./build/libs\n  \n   # Extract jar\n  java -Djarmode=layertools -jar spring-docker-setup-0.0.1-SNAPSHOT.jar extract\n  ```\n  \n* Analyse created directories(application, dependencies, snapshot-dependencies and spring-boot-loader) \n\n## Other Useful Commands\n\n| Command | Description | \n| -------------:|:--------:|\n| `./gradlew tasks` | Display all available tasks |\n| `./gradlew bootRun` | Run Spring boot application |\n| `./gradlew bootRun --args='--spring.profiles.active=docker'` | Run Spring boot application with 'docker' profile |\n| `./gradlew displayDockerImageName` | Displays docker image name |\n| `./gradlew displaySampleDockerCompose` | Displays sample docker compose file  |\n| `./gradlew bootBuildImage` | Build docker image using spring boot plugin|\n| `./gradlew bootAppComposeUp` | Start application using docker compose plugin |\n| `./gradlew bootAppComposeDown` | Stop application using docker compose plugin |\n| `./gradlew jibDockerBuild` | Build docker image using jib |\n\n## References\n\n* [Production-grade Spring Boot Docker images](https://pete-woods.com/2019/02/production-grade-spring-boot-docker-images/)\n* [Creating Efficient Docker Images with Spring Boot 2.3](https://spring.io/blog/2020/08/14/creating-efficient-docker-images-with-spring-boot-2-3)\n* [Jib plugin](https://github.com/GoogleContainerTools/jib)\n* [Gradle docker-compose plugin](https://github.com/avast/gradle-docker-compose-plugin)\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbiedrawa%2Fspring-docker-gradle-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbiedrawa%2Fspring-docker-gradle-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbiedrawa%2Fspring-docker-gradle-setup/lists"}