commit 63c708183b7770eb64fb838392c08ec586acefcd Author: Ben Vincent Date: Sat Nov 23 13:52:13 2024 +1100 feat: add terragrunt - add makefile for all builds - add .gitignore - add terragrunt dockerfile/nfpm diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..335e7b3 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,30 @@ +name: Build + +on: + pull_request: + +jobs: + build: + runs-on: almalinux-8 + container: + image: git.query.consul/unkin/almalinux8:latest + options: --privileged + + steps: + - name: Set up environment + run: | + dnf install -y yum-utils + yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + dnf module enable -y nodejs:20 + dnf install -y docker-ce-cli make bash git nodejs + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build Docker Image + run: | + make build + + - name: Show tree + run: | + tree /workspace diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..1ceda77 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,26 @@ +name: Build + +on: + pull_request: + +jobs: + build: + runs-on: almalinux-8 + container: + image: git.query.consul/unkin/almalinux8:latest + options: --privileged + + steps: + - name: Set up environment + run: | + dnf install -y yum-utils + yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + dnf module enable -y nodejs:20 + dnf install -y docker-ce-cli make bash git nodejs + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build Docker Image + run: | + make build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..46e07cd --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +# Variables +ROOT_DIR := $(PWD) +RPMS_DIR := $(ROOT_DIR)/rpms +NFPM_VERSION := 2.41.1 + +# Automatically find all package/version directories +PACKAGES := $(shell find $(RPMS_DIR) -mindepth 2 -maxdepth 2 -type d | sed "s|$(RPMS_DIR)/||") + +# Default target to build all packages and versions +.PHONY: all +all: $(PACKAGES) + +# Build specific package/version +.PHONY: $(PACKAGES) +$(PACKAGES): + @PACKAGE_NAME=$(shell echo $(@) | cut -d/ -f1) && \ + PACKAGE_VERSION=$(shell echo $(@) | cut -d/ -f2) && \ + echo "Building RPM for $$PACKAGE_NAME version $$PACKAGE_VERSION" && \ + $(MAKE) build PACKAGE_NAME=$$PACKAGE_NAME PACKAGE_VERSION=$$PACKAGE_VERSION + +# Build target +.PHONY: build +build: + @mkdir -p $(ROOT_DIR)/dist/$(PACKAGE_NAME)/ + @echo "Preparing to build $(PACKAGE_NAME) version $(PACKAGE_VERSION)" + @cd $(RPMS_DIR)/$(PACKAGE_NAME) && \ + export PACKAGE_RELEASE=$$(cat $(PACKAGE_VERSION)/release) && \ + echo "Using PACKAGE_RELEASE=$${PACKAGE_RELEASE}" && \ + docker build \ + --build-arg NFPM_VERSION=$(NFPM_VERSION) \ + --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) \ + --build-arg PACKAGE_RELEASE=$${PACKAGE_RELEASE} \ + -t $$(echo $(PACKAGE_NAME)-builder \ + | tr '[:upper:]' '[:lower:]') . && \ + docker create --name $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder \ + $$(echo $(PACKAGE_NAME)-builder | tr '[:upper:]' '[:lower:]') && \ + docker start -a $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder && \ + docker cp $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder:/app/dist/. $(ROOT_DIR)/dist/$(PACKAGE_NAME)/ && \ + docker rm $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder + +# Clean target +.PHONY: clean +clean: + @echo "Cleaning build artifacts..." + rm -rf $(ROOT_DIR)/dist diff --git a/rpms/terragrunt/0.68.14/deploy b/rpms/terragrunt/0.68.14/deploy new file mode 100644 index 0000000..1621a8b --- /dev/null +++ b/rpms/terragrunt/0.68.14/deploy @@ -0,0 +1 @@ +almalinux/el8 diff --git a/rpms/terragrunt/0.68.14/release b/rpms/terragrunt/0.68.14/release new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/rpms/terragrunt/0.68.14/release @@ -0,0 +1 @@ +1 diff --git a/rpms/terragrunt/Dockerfile b/rpms/terragrunt/Dockerfile new file mode 100644 index 0000000..b7593af --- /dev/null +++ b/rpms/terragrunt/Dockerfile @@ -0,0 +1,35 @@ +# Start with the AlmaLinux 8.10 base image +FROM git.query.consul/unkin/almalinux8:latest + +# Create output directory for RPMs +RUN mkdir -p /app/dist + +# Set working directory +WORKDIR /app + +ARG PACKAGE_RELEASE +ENV PACKAGE_RELEASE=${PACKAGE_RELEASE} +ARG PACKAGE_VERSION +ENV PACKAGE_VERSION=${PACKAGE_VERSION} +ARG NFPM_VERSION +ENV NFPM_VERSION=${NFPM_VERSION} + +# Clean and update the repository cache +RUN dnf clean all && \ + dnf makecache + +# Install build tools and dependencies for building RPMs +RUN dnf groupinstall -y 'Development Tools' && \ + dnf install -y make cmake gcc gcc-c++ rpm rpmdevtools wget tar gzip + +# Install nfpm using the RPM package +RUN dnf install -y https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm-${NFPM_VERSION}-1.x86_64.rpm + +# Copy nfpm.yaml from the context into the container +COPY nfpm.yaml /app/nfpm.yaml + +# Download the required files +RUN wget -O /app/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v${PACKAGE_VERSION}/terragrunt_linux_amd64 + +# Default command to build RPMs +CMD nfpm pkg --config /app/nfpm.yaml --target /app/dist --packager rpm diff --git a/rpms/terragrunt/nfpm.yaml b/rpms/terragrunt/nfpm.yaml new file mode 100644 index 0000000..e12ad4e --- /dev/null +++ b/rpms/terragrunt/nfpm.yaml @@ -0,0 +1,35 @@ +# nfpm.yaml + +name: terragrunt +version: ${PACKAGE_VERSION} +release: ${PACKAGE_RELEASE} +arch: amd64 +platform: linux +section: default +priority: extra +description: "Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale." + +maintainer: Ben Vincent +homepage: https://github.com/gruntwork-io/terragrunt +license: MIT + +disable_globbing: false + +replaces: + - terragrunt + +# Files to include in the package +contents: + - src: /app/terragrunt + dst: /usr/local/bin/terragrunt + file_info: + mode: 0755 + owner: root + group: root + +# Scripts to run during installation/removal (optional) +# scripts: +# preinstall: ./scripts/preinstall.sh +# postinstall: ./scripts/postinstall.sh +# preremove: ./scripts/preremove.sh +# postremove: ./scripts/postremove.sh