- Removed old requirements.txt and test_new_format.py files. - Added new src/cisco_mac_http_service.py to implement an HTTPS service for MAC monitoring. - Introduced src/cisco_mac_monitor.py for the main MAC monitoring functionality. - Created new requirements.txt for dependencies. - Added example usage documentation in Docs/example. - Updated test_new_format.py to validate new JSON output format.
63 lines
1.8 KiB
Docker
63 lines
1.8 KiB
Docker
# Dockerfile para Cisco MAC Monitor HTTPS Service
|
|
# ===============================================
|
|
FROM rockylinux:8
|
|
|
|
# Metadatos
|
|
LABEL maintainer="Equipo de Monitorización de Red"
|
|
LABEL description="Monitor de direcciones MAC para Cisco via HTTPS API con soporte SSH legacy"
|
|
LABEL version="2.1-https-service"
|
|
|
|
# Variables de entorno
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV LANG=en_US.UTF-8
|
|
ENV LC_ALL=en_US.UTF-8
|
|
|
|
# Variables para el servicio HTTPS
|
|
ENV HTTP_HOST=0.0.0.0
|
|
ENV HTTP_PORT=8443
|
|
|
|
# Actualizar sistema e instalar dependencias base
|
|
RUN dnf update -y && \
|
|
dnf install -y \
|
|
python3 \
|
|
python3-pip \
|
|
python3-devel \
|
|
openssh-clients \
|
|
gcc \
|
|
openssl-devel \
|
|
libffi-devel \
|
|
krb5-devel \
|
|
curl \
|
|
openssl && \
|
|
dnf clean all
|
|
|
|
# Crear usuario no privilegiado
|
|
RUN useradd -m -u 1000 -s /bin/bash monitor
|
|
|
|
# Copiar requirements.txt primero para cache de Docker
|
|
COPY src/requirements.txt /tmp/requirements.txt
|
|
|
|
# Instalar dependencias Python desde requirements.txt
|
|
RUN pip3 install --no-cache-dir --upgrade pip && \
|
|
pip3 install --no-cache-dir -r /tmp/requirements.txt && \
|
|
rm /tmp/requirements.txt
|
|
|
|
# Cambiar al usuario no privilegiado
|
|
USER monitor
|
|
WORKDIR /app
|
|
|
|
# Copiar scripts principales
|
|
COPY --chmod=755 --chown=monitor:monitor src/cisco_mac_monitor.py /app/
|
|
COPY --chmod=755 --chown=monitor:monitor src/cisco_mac_http_service.py /app/
|
|
|
|
# Exponer puerto HTTPS
|
|
EXPOSE 8443
|
|
|
|
# Healthcheck para el servicio HTTPS
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
|
CMD curl -k -f https://localhost:8443/health || exit 1
|
|
|
|
# Entry point para el servicio HTTPS
|
|
ENTRYPOINT ["python3", "/app/cisco_mac_http_service.py"]
|
|
CMD ["--host", "0.0.0.0", "--port", "8443"] |