A Docker image optimized for building and pushing Docker images in GitLab CI pipelines.
465
A Docker image optimized for building and pushing Docker images in GitLab CI pipelines. This image is designed to streamline the process of versioning, building, and pushing Docker images, as well as notifying build results via Telegram.
docker:latest: Provides full Docker capabilities for managing builds within CI pipelines.bash and curl for enhanced scripting and notifications.docker_build_push.sh: Automates the Docker image build and push process, including handling version tagging.notify_telegram.sh: Sends build success or failure notifications to Telegram, including deployment options.define_version_tags.sh: Centralized version and image tag generation logic for consistent versioning across scripts.This image is designed to be used in GitLab CI pipelines where building and pushing Docker images is required. Currently only Telegram is available for sending notifications, which are not required.
docker-build:
stage: dockerize
image: zeacom/gitlab-docker-build:v1.0.0
services:
- docker:dind
script:
- /usr/local/bin/docker_build_push.sh
after_script:
- /usr/local/bin/notify_telegram.sh
docker_build_push.sh
This script automates the Docker build and push process. It generates version tags based on GitLab CI environment variables and pushes the resulting image to the Docker registry.
notify_telegram.sh
Sends a notification to a specified Telegram chat with information about the build status. It uses Telegram's Bot API to send success or error messages, including deployment options if the build is successful.
define_version_tags.sh
Generates Docker image version tags based on the GitLab CI commit reference or tag. It ensures consistent versioning across builds.
To use this image effectively, certain environment variables are required:
CI_COMMIT_REF_NAME: GitLab commit reference, used for versioning.
CI_PIPELINE_URL: The URL to the current pipeline for notifications.
TELEGRAM_CHAT_ID: The Telegram chat ID where notifications will be sent.
TELEGRAM_CHAT_TOKEN: Token for the Telegram bot used for notifications.
You can customize the behavior of the build and push process by modifying the pre-installed scripts or adding new ones to the image.
To use this image for building Docker images, the docker_build_push.sh script must be executed. It handles the Docker login, build, and push steps automatically, using versioning logic from define_version_tags.sh.
This Docker image is licensed under the MIT License.
Content type
Image
Digest
sha256:ab321e6b4…
Size
222.1 MB
Last updated
almost 2 years ago
docker pull zeacom/gitlab-docker-build:v1.0.3