Skip to content

WouterGritter/docker-build-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-build-helper

My personal script for quickly and easily building and pushing Docker images to work with my own local registry, based on a couple questions with default values that it asks on each run. The script has multi-platform support, automatically generates image names based on the CWD, automatically generates image tags based on the current date and previously built images, and adds an IMAGE_VERSION build argument.

The suggested image name defaults to the current directory name, but can be overridden per project by placing a .docker-image-name file in the project directory containing the desired image name.

This script might be useful for you if you have a similar setup to mine. To get it up and running, copy and paste .env.example to .env and fill in the REGISTRY environment variable. After that, just run the script while in the directory of the docker project you want to build, tag and push.

Personally I have this script and the corresponding .env file located in my home directory, such that I can easily execute ~/docker_build while in a Docker project folder.

Example output / flow

Example output when executed in the project directory of tapo-mqtt-bridge.

wouter@wouter-asus:~/dev/tapo_mqtt_bridge$ ~/docker_build
Docker registry is set as registry.local.
Please enter the Docker image name [tapo-mqtt-bridge]:
Please enter the Docker image version (tag) [250901]:
Should a latest tag be pushed? [Y/n]:
Available platforms:
 - amd = linux/amd64
 - arm = linux/arm64
Which platforms should the image be built for? [amd,arm]:
Generated the following docker build command:
docker buildx build --platform linux/amd64,linux/arm64 --tag registry.local/tapo-mqtt-bridge:250901 --tag registry.local/tapo-mqtt-bridge:latest --build-arg IMAGE_VERSION=250901 --push .
Execute this build command? [Y/n]:
[+] Building 2.5s (22/22) FINISHED                                                                    docker-container:multi-builder
 => [internal] load build definition from Dockerfile                                                                            0.0s
... docker command output omitted
Successfully built image registry.local/tapo-mqtt-bridge:250901

About

Script to generate and execute docker build commands.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages