2025-04-11 08:56:00
github.com
When building containerized environments using standard Dockerfiles, each customization layer creates:
- Storage bloat – Every RUN apt-get install creates a new layer, wasting disk space with duplicate dependencies
- Network inefficiency – Redundant package downloads occur across different images
- Slow iterations – Rebuilding images requires repeating all previous steps
With this tool one can build:
- Minimal base images from scratch using debootstrap
- Precisely including only required components in the initial build
- Creating specialized variants (Java, Kafka, etc.) from common foundations
Usage: make
============================
** Debian Linux targets **
============================
|all|
|debian11|
|debian11-java|
|debian11-java-slim|
|debian11-corretto|
|debian11-graal|
|debian11-graal-slim|
|debian11-java-slim-maven|
|debian11-java-slim-gradle|
|debian11-graal-slim-maven|
|debian11-graal-slim-gradle|
|debian11-java-kafka|
|debian11-java-slim-kafka|
[Image was built successfully]
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Artifact location: debian/dist/debian11-graal-slim/debian11-graal-slim.tar
Artifact size: 124M
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Image was built successfully!
Artifact location: debian/dist/debian11-graal-slim/debian11-graal-slim.tar
To load and run this Docker image, follow these steps:
Load the Docker image from the .tar file:
cat debian/dist/debian11-graal-slim/debian11-graal-slim.tar | docker import - debian/dist/debian11-graal-slim/debian11-graal-slim
Verify the image was loaded successfully:
docker images
Run the Docker container:
docker run -it
Replace with the name of the image loaded in the first step.
Example:
docker run -it debian/dist/debian11-graal-slim/debian11-graal-slim /bin/bash
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Time elapsed: 193
- Add recipe to recipes/
- Make sure that the link to artifact and SHA256 is correct (e.g
sha256sum kafka_2.13-4.0.0.tgz
):
KAFKA_VERSION='4.0.0'
KAFKA_SHA='7b852e938bc09de10cd96eca3755258c7d25fb89dbdd76305717607e1835e2aa'
KAFKA_URL="https://downloads.apache.org/kafka/${KAFKA_VERSION}/kafka_2.13-${KAFKA_VERSION}.tgz"
- Add target to the Makefile
debian11-java-slim-kafka:
$(PRINT_HEADER)
$(DEBIAN_BUILD_SCRIPT) \
--name=$@ \
--keyring=$(DEBIAN_KEYRING) \
--variant=container \
--release=stable \
--recipes=$(JAVA_RECIPES)/java_slim.sh,$(RECIPES)/kafka/kafka.sh \
--scripts=$(SCRIPTS)/security-scan.sh
Profit
Dockerfile
– Docker configuration for building the environmentMakefile
– Build automation with targets for different imagesREADME.md
– Project documentation and usage instructionstools.mk
– Makefile tools and utilitiesVagrantfile
– Vagrant configuration for development environment
Contains Debian-specific files for image building
Configuration files for different Debian versions:
buster
– Debian 10 (Buster) configbullseye
– Debian 11 (Bullseye) configjessie
– Debian 8 (Jessie) configstretch
– Debian 9 (Stretch) configunstable
– Debian Unstable configwheezy
– Debian 7 (Wheezy) config
GPG keys for package verification:
buster.gpg
– Key for Debian Busterunstable.gpg
– Key for Debian Unstable
mkimage.sh
– Main script for building Debian root filesystems
Contains installation scripts for different components
Java-related installation scripts:
java.sh
– Full JDK installationjava_slim.sh
– Slimmed-down JDK installationgraalvm.sh
– GraalVM installationgraalvm_slim.sh
– Slim GraalVM installationcorretto.sh
– Amazon Corretto JDKmaven.sh
– Apache Mavengradle.sh
– Gradle build tool
kafka.sh
– Apache Kafka installation (added in our solution)
Post-build maintenance scripts:
security-scan.sh
– Runs Trivy security scanner
Output directory (created during build):
- Contains final built images in
.tar
format - Organized by image name (e.g.,
debian11-java-slim/
)
Temporary download directory (created during build):
- Stores downloaded packages and binaries
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Help Power Techcratic’s Future – Scan To Support
If Techcratic’s content and insights have helped you, consider giving back by supporting the platform with crypto. Every contribution makes a difference, whether it’s for high-quality content, server maintenance, or future updates. Techcratic is constantly evolving, and your support helps drive that progress.
As a solo operator who wears all the hats, creating content, managing the tech, and running the site, your support allows me to stay focused on delivering valuable resources. Your support keeps everything running smoothly and enables me to continue creating the content you love. I’m deeply grateful for your support, it truly means the world to me! Thank you!
BITCOIN bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge Scan the QR code with your crypto wallet app |
DOGECOIN D64GwvvYQxFXYyan3oQCrmWfidf6T3JpBA Scan the QR code with your crypto wallet app |
ETHEREUM 0xe9BC980DF3d985730dA827996B43E4A62CCBAA7a Scan the QR code with your crypto wallet app |
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.