From b928a044f75c110a40d138b495f31408e5f86622 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 1 Jul 2025 23:27:05 +0930 Subject: [PATCH] refactor(docker): use arg to set rulebook name ref: #3 #1 --- dockerfile | 15 +++++++++------ includes/entrypoint.sh | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 includes/entrypoint.sh diff --git a/dockerfile b/dockerfile index 7f96b03..156f57b 100644 --- a/dockerfile +++ b/dockerfile @@ -1,3 +1,4 @@ +ARG GIT_EVENT_RULEBOOK_NAME='problem_matcher' FROM python:3.11-alpine3.22 AS Build @@ -49,9 +50,13 @@ RUN cd /tmp/python_modules; \ + FROM python:3.11-alpine3.22 +ARG GIT_EVENT_RULEBOOK_NAME + + RUN apk --no-cache update; \ apk --no-cache add \ openjdk21-jdk @@ -63,6 +68,8 @@ ENV ANSIBLE_INVENTORY hosts.yaml ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk +ENV GIT_EVENT_RULEBOOK_NAME ${GIT_EVENT_RULEBOOK_NAME} + COPY includes/ / @@ -80,6 +87,7 @@ RUN pip install --no-cache-dir /tmp/python_builds/*; \ rm -rf /home/eda/.ansible/collections/ansible_collections/nofusscomputing/git_events/includes; \ mv /usr/bin/annotations.py /usr/bin/annotations; \ chmod +x /usr/bin/annotations; \ + chmod +x /entrypoint.sh; \ chown eda:eda -R /home/eda; @@ -89,9 +97,4 @@ WORKDIR /home/eda USER eda -CMD [ \ - "ansible-rulebook", \ - "-r", "nofusscomputing.git_events.webhook", \ - "--env-vars", "PROBLEM_MATCHER_PORT,PROBLEM_MATCHER_TOKEN", \ - "-v" \ -] +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/includes/entrypoint.sh b/includes/entrypoint.sh new file mode 100644 index 0000000..38517b6 --- /dev/null +++ b/includes/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +if [ $# -eq 0 ]; then + + cd ${HOME}; + + ansible-rulebook \ + -r nofusscomputing.git_events.${GIT_EVENT_RULEBOOK_NAME} \ + --env-vars PROBLEM_MATCHER_PORT,PROBLEM_MATCHER_TOKEN \ + -v; + +else + + exec "$@" + +fi