Build Spring Docker images using JDK 21 and Gradle 8.7, and push them to the host's Docker registry.
177
docker build -t cybicom/dockerize-boot-services:1.0.0 -f Dockerfile.cli
docker build -t cybicom/dockerize-boot-services:1.0.0 .
docker push cybicom/dockerize-boot-services:1.0.0
docker push cybicom/dockerize-boot-services:slim-1.0.0
This Docker image is designed to automate the building of Spring Boot repositories into Docker images using JDK 21 and Gradle 8.7, and subsequently push them to the host's Docker registry. It supports selective building and tagging through a CLI if enabled.
To use this image, ensure you have Docker installed on your host machine. Pull the image from Docker Hub and run a container with the required volume mounts and environment variables.
docker pull cybicom/dockerize-boot-services:1.0.0
docker pull cybicom/dockerize-boot-services:slim-1.0.0
Use the following command to run the container:
docker run -it -v %PROJECTS%:/app/projects -v /var/run/docker.sock:/var/run/docker.sock -e CLI cybicom/dockerize-boot-services:1.0.0
node run-docker.mjs
This has the cli on the outside and will use the slim version and will run one docker image for each project selected.
The script executes this docker run command for each selected project (you could of course also execute it directly from the terminal with %?% filled in):
docker run -it -v %PROJECTS%:/app/projects -v /var/run/docker.sock:/var/run/docker.sock -e PROJECT_NAME=%PROJECT_NAME% -e DOCKER_TAG=%DOCKER_TAG% cybicom/dockerize-boot-services:slim-1.0.0
This version is used by repo ci/cd, as a build runner.
Projects Directory: Mount your local projects directory to /app/projects in the container. Replace %PROJECTS% with the path to your projects directory on your host.
Docker Socket: Mounts the Docker socket to allow the container to communicate with the host Docker daemon, enabling it to push new images to the host's Docker registry.
CLI: Set this environment variable to true to enable the command-line interface features within the container. When enabled, you can choose specific repositories to build and specify a tag version. If not enabled, all repositories are built and published with the 'latest' tag. Only available in non-slim version
PROJECT_NAME: Specify a single project name, within /app/projects if you want to build just one project. This is typically used with automation or scripts that target specific projects.
DOCKER_TAG: Use this to define a custom tag for the built Docker images. Defaults to 'latest' if not specified.
After running the container, the behavior depends on the provided environment variables:
-e PROJECT_NAME is provided, the container will build only the specified project. This is useful for targeted builds, such as in automated pipelines or for specific deployment tasks. (assuming your directory structure is setup so all your repos are cloned into one parent directory - the script skips non-spring-boot projects)This process simplifies the deployment of multiple Spring Boot applications by automating their containerization.
For more information and updates, visit either
Docker Hub
Github Repo
Content type
Image
Digest
sha256:5a15c3e7d…
Size
296.1 MB
Last updated
over 2 years ago
docker pull cybicom/dockerize-boot-services:slim-1.0.0