-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (52 loc) · 2.42 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (52 loc) · 2.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# ── Stage 1: base ────────────────────────────────────────────────
FROM python:3.15-rc-slim-trixie AS base
ARG INSTALL_EDGETPU=true
ENV PYTHONUNBUFFERED=1
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpcap0.8 \
usbutils \
gnupg \
curl && \
if [ "$INSTALL_EDGETPU" = "true" ]; then \
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| gpg --dearmor -o /usr/share/keyrings/coral-edgetpu.gpg && \
echo "deb [signed-by=/usr/share/keyrings/coral-edgetpu.gpg] https://packages.cloud.google.com/apt coral-edgetpu-stable main" \
> /etc/apt/sources.list.d/coral-edgetpu.list && \
apt-get update && \
apt-get install -y --no-install-recommends libedgetpu1-std; \
fi && \
apt-get purge -y gnupg curl && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# ── Stage 2: runtime (default) ──────────────────────────────────
FROM base AS runtime
COPY pyproject.toml README.md ./
COPY cocosentry/ cocosentry/
RUN pip install --no-cache-dir ".[coral,mqtt]"
COPY config.example.toml .
# Create non-root user for runtime.
# Note: The container still requires privileged mode and host networking
# for USB device access (WiFi Coconut adapter and Coral Edge TPU).
RUN groupadd -r cocosentry && \
useradd -r -g cocosentry -d /app -s /sbin/nologin cocosentry && \
mkdir -p /app/models /data && \
chown -R cocosentry:cocosentry /app /data
USER cocosentry
ENTRYPOINT ["python", "-m", "cocosentry"]
CMD ["--config", "/app/config.toml", "-v"]
# ── Stage 3: training ───────────────────────────────────────────
FROM runtime AS training
USER root
RUN pip install --no-cache-dir ".[training]"
USER cocosentry
COPY training/ training/
ENTRYPOINT ["python"]
# ── Stage 4: dev ─────────────────────────────────────────────────
FROM training AS dev
USER root
RUN pip install --no-cache-dir ".[dev]"
USER cocosentry
COPY tests/ tests/
ENTRYPOINT ["python", "-m", "pytest"]