feat(docker): container that launches server and scanner in one

!1
This commit is contained in:
2024-02-21 00:26:40 +09:30
parent add0b2390b
commit f9af64e7a1
10 changed files with 474 additions and 2 deletions

126
dockerfile Normal file
View File

@ -0,0 +1,126 @@
FROM python:3.11-alpine3.19 as build
RUN apk update; \
apk add gcc
RUN pip install --upgrade \
setuptools \
wheel
RUN apk add openjdk21-jdk;
RUN apk add \
alpine-sdk \
libffi-dev \
maven;
ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk
COPY requirements.txt /tmp/requirements.txt
RUN mkdir -p /tmp/python_modules; \
cd /tmp/python_modules; \
pip download --dest . --check-build-dependencies \
supervisor==4.2.5 \
-r /tmp/requirements.txt
RUN mkdir -p /tmp/python_builds;
RUN cd /tmp/python_modules; \
mkdir -p /tmp/python_builds; \
echo "[DEBUG] PATH=$PATH"; \
pip wheel --wheel-dir /tmp/python_builds --find-links . *.whl; \
pip wheel --wheel-dir /tmp/python_builds --find-links . *.tar.gz;
RUN echo $(date)\
cd /tmp; \
ls -laR /tmp
FROM python:3.11-alpine3.19
LABEL \
# org.opencontainers.image.authors="{contributor url}" \
# org.opencontainers.image.url="{dockerhub url}" \
# org.opencontainers.image.documentation="{docs url}" \
# org.opencontainers.image.source="{repo url}" \
# org.opencontainers.image.revision="{git commit sha at time of build}" \
org.opencontainers.image.title="No Fuss Computings phpIPAM Scan Agent" \
org.opencontainers.image.description="A phpIPAM Scan agent for local and remote networks" \
org.opencontainers.image.vendor="No Fuss Computing"
# org.opencontainers.image.version="{git tag}"
RUN apk --no-cache update; \
apk add \
openjdk21-jdk \
git \
dcron \
nmap;
ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk
COPY --from=build /tmp/python_builds /tmp/python_builds
RUN chmod 644 -R /etc/cron.d; \
pip install /tmp/python_builds/*; \
rm -R /tmp/python_builds
ARG COLLECTION_COMMIT=none
ARG COLLECTION_BRANCH=development
ARG COLLECTION_PACKAGE=dev
COPY includes/ /
RUN mkdir -p /tmp/collection; \
if [ "$COLLECTION_PACKAGE" != "dev" ]; then \
echo "specified"; \
ansible-galaxy collection install --force-with-deps --pre \
$COLLECTION; \
elif [ "$COLLECTION_PACKAGE" == "dev" ]; then \
git clone \
--depth=1 \
-b $COLLECTION_BRANCH \
https://gitlab.com/nofusscomputing/projects/ansible/collections/phpipam_scan_agent.git \
/tmp/collection; \
if [ "${COLLECTION_COMMIT}" != "none" ]; then git switch $COLLECTION_COMMIT; fi; \
ansible-galaxy collection install --force-with-deps --pre \
/tmp/collection/.; \
rm -Rf /tmp/collection; \
fi; \
chmod +x /etc/cron.d/*;
WORKDIR /root
HEALTHCHECK --interval=10s --timeout=10s --start-period=5s --retries=3 CMD \
supervisorctl status || exit 1
ENV HTTP_PORT 5000
ENV ANSIBLE_FORCE_COLOR 'true'
ENV ANSIBLE_LOG_PATH /var/log/ansible.log
CMD [ "/usr/local/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf" ]