From e8cc0ac6dbea9490125e1668a5d741d8e5f5046e Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 25 Aug 2024 17:01:50 +1000 Subject: [PATCH] feat: create base almalinux 8.10 image - add drone.yml - add makefile - add Dockerfile - add repos --- .drone.yml | 25 +++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++++++++ files/appstream.repo | 6 ++++++ files/baseos.repo | 6 ++++++ files/epel.repo | 6 ++++++ files/powertools.repo | 6 ++++++ makefile | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 files/appstream.repo create mode 100644 files/baseos.repo create mode 100644 files/epel.repo create mode 100644 files/powertools.repo create mode 100644 makefile diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..20b6d25 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,25 @@ +kind: pipeline +type: docker +name: build-docker-image + +steps: + - name: build + image: docker:20.10.24-dind + environment: + DOCKER_HOST: tcp://localhost:2375 # Docker daemon + DOCKER_TLS_CERTDIR: '' # Disable TLS to simplify DIND setup + volumes: + - name: dockersock + path: /var/run/docker.sock + commands: + - apk add --no-cache make bash git + - make build + +volumes: + - name: dockersock + temp: {} + +trigger: + event: + - push + - pull_request diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f19f4e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Start with the base AlmaLinux 8.10 image +FROM almalinux:8.10 + +# Remove existing repos and copy custom repo files into the container +RUN rm -rf /etc/yum.repos.d/*.repo + +# Copy from the local context into the container +COPY files/*.repo /etc/yum.repos.d/ + +# Clean and update the repository cache +RUN dnf clean all && \ + dnf makecache + +# Update the system and install required packages +RUN dnf update -y && \ + dnf install -y curl git && \ + dnf clean all && \ + rm -rf /var/cache/dnf diff --git a/files/appstream.repo b/files/appstream.repo new file mode 100644 index 0000000..ed8eceb --- /dev/null +++ b/files/appstream.repo @@ -0,0 +1,6 @@ +[appstream] +name=appstream repository +baseurl=http://edgecache.query.consul/almalinux/8.10/AppStream/x86_64/os +gpgkey=http://edgecache.query.consul/almalinux/RPM-GPG-KEY-AlmaLinux-8 +enabled=1 +gpgcheck=1 diff --git a/files/baseos.repo b/files/baseos.repo new file mode 100644 index 0000000..3d6ec72 --- /dev/null +++ b/files/baseos.repo @@ -0,0 +1,6 @@ +[baseos] +name=baseos repository +baseurl=http://edgecache.query.consul/almalinux/8.10/BaseOS/x86_64/os +gpgkey=http://edgecache.query.consul/almalinux/RPM-GPG-KEY-AlmaLinux-8 +enabled=1 +gpgcheck=1 diff --git a/files/epel.repo b/files/epel.repo new file mode 100644 index 0000000..b096733 --- /dev/null +++ b/files/epel.repo @@ -0,0 +1,6 @@ +[epel] +name=epel repository +baseurl=http://edgecache.query.consul/epel/8/Everything/x86_64 +gpgkey=http://edgecache.query.consul/epel/RPM-GPG-KEY-EPEL-8 +enabled=1 +gpgcheck=1 diff --git a/files/powertools.repo b/files/powertools.repo new file mode 100644 index 0000000..62dc01e --- /dev/null +++ b/files/powertools.repo @@ -0,0 +1,6 @@ +[powertools] +name=powertools repository +baseurl=http://edgecache.query.consul/almalinux/8.10/PowerTools/x86_64/os +gpgkey=http://edgecache.query.consul/almalinux/RPM-GPG-KEY-AlmaLinux-8 +enabled=1 +gpgcheck=1 diff --git a/makefile b/makefile new file mode 100644 index 0000000..7544759 --- /dev/null +++ b/makefile @@ -0,0 +1,33 @@ +# Get the current Git commit hash +GIT_COMMIT := $(shell git rev-parse --short HEAD) + +# Get the current date in YYYYMMDD format +DATE_TAG := $(shell date +%Y%m%d) + +# Set the Docker image name and repository information +IMAGE_NAME := almalinux8 +REGISTRY := git.query.consul +OWNER := unkin + +# Build the Docker image (without tags) +build: + docker build --network=host -t $(IMAGE_NAME) . + +# Tag the Docker image with the Git commit hash, the date, and 'latest' +tag: + docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT) + docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG) + docker tag $(IMAGE_NAME):latest $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest + +# Push the Docker image to a repository with all tags +push: tag + docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(GIT_COMMIT) + docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):$(DATE_TAG) + docker push $(REGISTRY)/$(OWNER)/$(IMAGE_NAME):latest + +# Clean up dangling Docker images +clean: + docker image prune -f + +# Default target +default: build