-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.py310
More file actions
90 lines (78 loc) · 2.62 KB
/
Dockerfile.py310
File metadata and controls
90 lines (78 loc) · 2.62 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Stage 1: Build Python 3.10
FROM debian:bookworm-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libssl-dev \
zlib1g-dev \
libncurses5-dev \
libgdbm-dev \
libnss3-dev \
libbz2-dev \
liblzma-dev \
libreadline-dev \
libffi-dev \
libsqlite3-dev \
wget \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Download and build Python 3.10
WORKDIR /tmp
RUN wget https://www.python.org/ftp/python/3.10.19/Python-3.10.19.tgz \
&& tar xzf Python-3.10.19.tgz \
&& cd Python-3.10.19 \
&& ./configure --enable-optimizations --prefix=/usr/local/python3.10 \
&& make -j$(nproc) \
&& make altinstall \
&& cd .. \
&& rm -rf Python-3.10.19.tgz Python-3.10.19
# Stage 2: Final minimal image
FROM debian:bookworm-slim AS oakapp
# Define build argument for architecture
ARG TARGETARCH
# Copy Python from builder stage
COPY --from=builder /usr/local/python3.10 /usr/local/python3.10
# Install runtime dependencies and create symlinks
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
libsqlite3-0 \
libffi8 \
libglib2.0-0 \
zlib1g \
ca-certificates \
runit \
nginx \
openssl \
wget \
curl \
jq \
git \
gettext \
glibc-source \
&& ln -s /usr/local/python3.10/bin/python3.10 /usr/local/bin/python \
&& ln -s /usr/local/python3.10/bin/python3.10 /usr/local/bin/python3 \
&& ln -s /usr/local/python3.10/bin/python3.10 /usr/local/bin/python3.10 \
&& ln -s /usr/local/python3.10/bin/pip3.10 /usr/local/bin/pip \
&& ln -s /usr/local/python3.10/bin/pip3.10 /usr/local/bin/pip3
# Ensure Python output is unbuffered for proper logging
ENV PYTHONUNBUFFERED=1
# Install DepthAI OS dependencies
RUN apt-get install -y libgl1 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
# Create service directories
RUN mkdir -p /etc/service/nginx /etc/service/oak_webrtc /etc/service/connection
# Add service run scripts
COPY --chmod=755 services/nginx-run.sh /etc/service/nginx/run
COPY --chmod=755 services/oak_webrtc-run.sh /etc/service/oak_webrtc/run
COPY --chmod=755 services/connection-run.sh /etc/service/connection/run
COPY --chmod=755 entrypoint.sh /entrypoint.sh
# Add oak_webrtc binary
COPY --chmod=755 oak_webrtc/$TARGETARCH/oak_webrtc /usr/local/bin/oak_webrtc
# Configure nginx and SSL
COPY /nginx/setup.sh /tmp/setup_nginx.sh
RUN chmod +x /tmp/setup_nginx.sh && \
/tmp/setup_nginx.sh && \
rm /tmp/setup_nginx.sh
COPY /nginx/server.template /etc/nginx/templates/site.template
COPY /nginx/nginx.conf /etc/nginx/nginx.conf