-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerfile
More file actions
38 lines (27 loc) · 1.06 KB
/
dockerfile
File metadata and controls
38 lines (27 loc) · 1.06 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
ARG TARGETARCH
# The base build, which should run on normal desktop computers
FROM python:3.11 AS build-amd64
WORKDIR /app
COPY pyproject.toml ./
# apt-update and install dependencies, with a cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get --no-install-recommends install -y python3-opencv gcc
# pip install dependencies, with a cache
RUN --mount=type=cache,target=/root/.cache \
pip install .
# Run last to not ruin the caches
COPY src/ ./src/
COPY models/best_float32.tflite ./models/
# Extra commands needed for arm64 (we're expecting it to be a Raspberry Pi)
FROM build-amd64 AS build-arm64
# install libcamera
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get --no-install-recommends install -y libcamera
RUN --mount=type=cache,target=/root/.cache \
pip install .[pi]
# Final build, using the detected architecture
FROM build-${TARGETARCH} AS final
EXPOSE 8080
CMD ["python", "-m", "src"]