-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (38 loc) · 1.42 KB
/
Dockerfile
File metadata and controls
50 lines (38 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SpectrumAlert Docker Image
FROM python:3.11-slim
# Install system dependencies for RTL-SDR
RUN apt-get update && apt-get install -y \
librtlsdr-dev \
rtl-sdr \
libusb-1.0-0-dev \
pkg-config \
build-essential \
udev \
python3-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Create app user (non-root for security)
RUN useradd -m -u 1000 spectrum && \
usermod -a -G plugdev spectrum
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create necessary directories
RUN mkdir -p /app/data /app/models /app/logs /app/config && \
chown -R spectrum:spectrum /app
# Copy RTL-SDR udev rules for device access
RUN echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", GROUP="plugdev", MODE="0666", SYMLINK+="rtl_sdr"' > /etc/udev/rules.d/20-rtlsdr.rules
# Switch to non-root user
USER spectrum
# Expose any ports if needed (for future web interface)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import sys; sys.path.insert(0, '/app/src'); from src.core.robust_collector import SafeRTLSDR; sdr = SafeRTLSDR(); print('healthy' if sdr.open() and sdr.close() else 'unhealthy')" || exit 1
# Default command (interactive mode)
CMD ["python", "main.py"]