diff --git a/.dockerignore b/.dockerignore index 6c1bca9..184c903 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,7 @@ +.ansible .git +CONTRIBUTING.md docs/ -# includes/ \ No newline at end of file +galaxy.yml +*.tmp.* + diff --git a/dockerfile b/dockerfile index efa1efa..7f96b03 100644 --- a/dockerfile +++ b/dockerfile @@ -1,45 +1,97 @@ -FROM harbor.earth.nww/docker/python:3.11-slim + +FROM python:3.11-alpine3.22 AS Build -RUN apt-get update; \ - apt-get install -y \ - curl \ - openjdk-17-jdk-headless; \ - pip install ansible-core ansible-rulebook; +RUN apk update; \ + apk add \ + build-base \ + gcc; -RUN addgroup eda; \ - adduser --ingroup eda eda -# COPY extensions/eda/rulebooks/webhook.yaml /eda/ +RUN pip install --upgrade \ + setuptools \ + wheel -RUN ansible-galaxy collection install ansible.eda -# RUN ls -la /home/eda/.ansible/collections/nofusscomputing/git_events/ +RUN apk add openjdk21-jdk; -COPY . /home/eda/.ansible/collections/ansible_collections/nofusscomputing/git_events/ -RUN pip install --no-cache-dir -r /home/eda/.ansible/collections/ansible_collections/nofusscomputing/git_events/requirements.txt +RUN apk add \ + alpine-sdk \ + libffi-dev \ + maven \ + build-base libc-dev; + + +ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk + +# ChatGPT suggestion to fix alpine version >3.19 +ENV CFLAGS "-Wno-incompatible-pointer-types" + + +COPY requirements.txt /tmp/requirements.txt + + +RUN mkdir -p /tmp/python_modules; \ + cd /tmp/python_modules; \ + pip download --dest . \ + pip \ + --check-build-dependencies \ + -r /tmp/requirements.txt + + +RUN cd /tmp/python_modules; \ + mkdir -p /tmp/python_builds; \ + echo "[DEBUG] PATH=$PATH"; \ + ls -l; \ + pip wheel --wheel-dir /tmp/python_builds --find-links . *.whl; \ + pip wheel --wheel-dir /tmp/python_builds --find-links . *.tar.gz; + + + +FROM python:3.11-alpine3.22 + + +RUN apk --no-cache update; \ + apk --no-cache add \ + openjdk21-jdk + + +ENV ANSIBLE_FORCE_COLOR true + +ENV ANSIBLE_INVENTORY hosts.yaml + +ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk + COPY includes/ / -RUN cp -r /root/.ansible /home/eda/; \ - # cp -r /home/eda/.ansible/collections/ansible_collections/nofusscomputing/git_events/includes/* /; \ +COPY . /home/eda/.ansible/collections/ansible_collections/nofusscomputing/git_events/ + +COPY --from=build /tmp/python_builds /tmp/python_builds + + +RUN pip install --no-cache-dir /tmp/python_builds/*; \ + rm -R /tmp/python_builds; \ + ansible-galaxy collection install ansible.eda; \ + addgroup eda; \ + adduser -D --ingroup eda eda; \ + cp -r /root/.ansible /home/eda/; \ 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; \ chown eda:eda -R /home/eda; + WORKDIR /home/eda -ENV ANSIBLE_INVENTORY hosts.yaml - -# required for parser script USER eda + CMD [ \ "ansible-rulebook", \ "-r", "nofusscomputing.git_events.webhook", \ "--env-vars", "PROBLEM_MATCHER_PORT,PROBLEM_MATCHER_TOKEN", \ "-v" \ -] \ No newline at end of file +] diff --git a/playbooks/problem_matcher.yaml b/playbooks/problem_matcher.yaml index 7911289..9c86de9 100644 --- a/playbooks/problem_matcher.yaml +++ b/playbooks/problem_matcher.yaml @@ -57,7 +57,7 @@ cat /tmp/job.log | annotations > /tmp/annotations.json; - executable: bash + executable: sh changed_when: false diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..2263dca --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ + +ansible-core==2.18.6 +ansible-rulebook==1.1.7 + +requests