Docker template repository
Go to file Use this template
2024-09-09 22:18:54 +10:00
.gitea/workflows feat: setup template repo 2024-09-08 02:16:51 +10:00
Dockerfile feat: setup template repo 2024-09-08 02:16:51 +10:00
Makefile feat: setup template repo 2024-09-08 02:16:51 +10:00
README.md chore: update readme 2024-09-09 22:16:26 +10:00

Docker Image Build: Almalinux Template

This project provides a reproducible Docker image build process for almalinux:8.10, with custom YUM repository configurations and package installations. The build is automated using a Makefile and managed via CI tasks to ensure consistent and reliable Docker image builds.

Makefile Overview

The Makefile provides several targets to automate building, tagging, and pushing Docker images. The Docker image is tagged with the current Git commit hash, the current date, and a latest tag for easy reference.

Makefile Targets

Build the Docker Image

To build the Docker image without tags:

make build

This will use the docker build command with --network=host to build the image with the name git.query.consul/unkin/almalinux8-template.

Tag the Docker Image

To tag the Docker image with the Git commit hash, the current date, and a latest tag:

make tag

This will add three tags to the image:

  • git.query.consul/unkin/almalinux8-template:<GIT_COMMIT>
  • git.query.consul/unkin/almalinux8-template:<DATE_TAG>
  • git.query.consul/unkin/almalinux8-template:latest

Push the Docker Image

To push the tagged Docker images to the registry:

make push

Note

: The push command is currently commented out for safety. To enable pushing, remove the comment (#) from the docker push lines in the push target.

Clean Up

To clean up any dangling Docker images:

make clean

This will remove any dangling (unused) Docker images using docker image prune -f.

Default Target

The default target is build. So running:

make

is equivalent to running make build.

Development and Testing

To test or develop with this Makefile, follow these steps:

  1. Clone the repository and navigate to the project directory:

    git clone https://git.query.consul/unkin/docker-template.git
    cd docker-template
    
  2. Build the Docker image using the build target:

    make build
    
  3. Tag the image with the commit hash, date, and latest tag:

    make tag
    
  4. (Optional) Modify the push target to enable pushing the image to your Docker registry: Uncomment the lines in the push target:

    docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT)
    docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG)
    docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest
    
  5. Test your changes locally by running the clean target:

    make clean