Files
IoT_PreTester_Demo/V4.5/Dockerfile.backend
T
2026-06-24 14:53:14 +02:00

80 lines
2.1 KiB
Docker

# Backend Dockerfile for IoT PreTester V3
# Python-based Django REST API with IoT analysis tools
FROM python:3.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive
# Set work directory
WORKDIR /app
# Install system dependencies and analysis tools
RUN apt-get update && apt-get install -y --no-install-recommends \
# Build essentials for Python packages
build-essential \
gcc \
g++ \
# Firmware analysis tools
binwalk \
file \
hashcat \
# Network analysis tools
tshark \
tcpdump \
nmap \
# Required libraries
libpcap-dev \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
# SQLite tools
sqlite3 \
# Utilities
wget \
pocl-opencl-icd \
ocl-icd-libopencl1 \
clinfo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user with explicit GID
RUN groupadd -g 1000 appgroup && \
useradd -m -u 1000 -g 1000 appuser && \
mkdir -p /app/data /app/files/firmware /app/files/pcap /app/files/wireshark_capture /app/logs /app/django_project/staticfiles && \
chown -R appuser:appgroup /app
# Copy requirements file
COPY requirements.txt /app/
# Upgrade pip and install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir gunicorn
# Copy project files
COPY --chown=appuser:appgroup django_project/ /app/django_project/
# Copy demo files
COPY --chown=appuser:appgroup demo_files/demo_firmware.bin /app/files/demo_firmware.bin
COPY --chown=appuser:appgroup demo_files/demo_capture.pcapng /app/files/demo_capture.pcapng
# Copy entrypoint script
COPY --chown=appuser:appgroup docker/entrypoint-backend.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Switch to non-root user
USER appuser
# Expose Django port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8000/api/get_all_manufacturers || exit 1
# Run entrypoint script
ENTRYPOINT ["/app/entrypoint.sh"]