From 173dc2d71905640343a3cefc058e50dd1ed062bf Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Wed, 28 Feb 2024 13:29:20 -0500 Subject: [PATCH] Add dynamic dependency args to dockerfile Add makefile for automating build and push commands --- Dockerfile | 7 +++++-- Makefile | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index 535afea..8ebb517 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,9 @@ RUN python -m pip wheel \ # ================================== FROM python:3.11-slim +ARG OPENTOFU_VERSION +ARG SEMAPHORE_VERSION + ENV SEMAPHORE_RUNNER_CONFIG_FILE /semaphore/config.json COPY --from=build /build/wheels /tmp/wheels @@ -37,8 +40,8 @@ RUN apt-get update --yes && \ curl \ gnupg && \ mkdir --parents /tmp/apt && \ - curl -sSL -o /tmp/apt/opentofu.deb https://github.com/opentofu/opentofu/releases/download/v1.6.2/tofu_1.6.2_amd64.deb && \ - curl -sSL -o /tmp/apt/semaphore.deb https://github.com/ansible-semaphore/semaphore/releases/download/v2.9.45/semaphore_2.9.45_linux_amd64.deb && \ + curl -sSL -o /tmp/apt/opentofu.deb https://github.com/opentofu/opentofu/releases/download/v${OPENTOFU_VERSION}/tofu_${OPENTOFU_VERSION}_amd64.deb && \ + curl -sSL -o /tmp/apt/semaphore.deb https://github.com/ansible-semaphore/semaphore/releases/download/v${SEMAPHORE_VERSION}/semaphore_${SEMAPHORE_VERSION}_linux_amd64.deb && \ apt-get install --yes /tmp/apt/*.deb && \ apt-get clean --yes && \ rm -rf /tmp/apt && \ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0549766 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +REPOSITORY = vcs.enp.one/skylab/semaphore-runner +OPENTOFU_VERSION = 1.6.2 +SEMAPHORE_VERSION = 2.9.45 + + +.PHONY: help docs +# source: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +help: ## List Makefile targets + $(info Makefile documentation) + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}' + + +image: ## Build image + podman build . --tag $(REPOSITORY):$(SEMAPHORE_VERSION) --build-arg "OPENTOFU_VERSION=$(OPENTOFU_VERSION)" --build-arg "SEMAPHORE_VERSION=$(SEMAPHORE_VERSION)" + +push: image ## Build and publish image + podman push $(REPOSITORY):$(SEMAPHORE_VERSION)