feat(docker): add alpine build

ref: #2 #1
This commit is contained in:
2025-07-01 03:56:59 +09:30
parent a7b2145886
commit aa368e4bfb
4 changed files with 82 additions and 21 deletions

View File

@ -1,3 +1,7 @@
.ansible
.git
CONTRIBUTING.md
docs/
# includes/
galaxy.yml
*.tmp.*

View File

@ -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" \
]
]

View File

@ -57,7 +57,7 @@
cat /tmp/job.log | annotations > /tmp/annotations.json;
executable: bash
executable: sh
changed_when: false

5
requirements.txt Normal file
View File

@ -0,0 +1,5 @@
ansible-core==2.18.6
ansible-rulebook==1.1.7
requests