-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
162 lines (144 loc) · 4.18 KB
/
Dockerfile
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Global build environment variables
ARG GST_INSTALL_DIR=/artifacts
ARG GST_VERSION=1.24.8
ARG LIBCAMERA_ENABLED=true
ARG LIBCAMERA_VERSION=v0.3.1
ARG RPICAM_ENABLED=false
ARG GST_OMX_ENABLED=false
# Stage 1: Base Image
FROM python:3.11.7-slim-bookworm AS base
RUN <<-EOF
set -e
# Add backports
echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free" >> "/etc/apt/sources.list"
# Setup cache
rm -f /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
EOF
# Stage 2: Build GStreamer
FROM base AS gstreamer
ARG GST_INSTALL_DIR
ARG GST_VERSION
ARG LIBCAMERA_ENABLED
ARG LIBCAMERA_VERSION
ARG RPICAM_ENABLED
ARG GST_OMX_ENABLED
COPY --link ./scripts/build_gst.sh /build_gst.sh
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=cache,target=/root/.cache,sharing=locked \
--mount=type=cache,target=/ccache,sharing=locked \
./build_gst.sh \
&& rm -f /build_gst.sh \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Stage 3: Final Image
FROM base AS main
ARG GST_INSTALL_DIR
ARG LIBCAMERA_ENABLED
ARG RPICAM_ENABLED
# Setup the user environment
RUN <<-EOF
set -e
RCFILE_PATH="/etc/blueosrc"
{
echo "alias cat='batcat --paging=never'"
echo "alias ls=exa"
echo "cd ~"
} >> "$RCFILE_PATH"
echo "source $RCFILE_PATH" >> "/etc/bash.bashrc"
EOF
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
# Install necessary tools and libs for basic use
apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
# TOOLS:
bat \
bzip2 \
curl \
dnsmasq \
dnsutils \
exa \
file \
gdbserver \
gettext \
hostapd \
htop \
i2c-tools \
ifmetric \
# Note: Remove iotop if htop is newer 3.2+
iotop \
iproute2 \
iperf3 \
iputils-ping \
iw \
jq \
less \
libudev-dev \
locate \
lsof \
mtr \
nano \
net-tools \
nginx \
parallel \
rsync \
screen \
ssh \
sshpass \
sudo \
tmux \
tree \
unzip \
vim \
watch \
wget \
# LIBS:
libatm1 \
libatomic1 \
libavcodec59 \
libavfilter8 \
libavformat59 \
libavutil57 \
libde265-0 \
libdrm2 \
libdv4 \
libglib2.0-0 \
libgudev-1.0-0 \
libjson-glib-1.0-0 \
libogg0 \
libopenjp2-7 \
libopus0 \
libpulse0 \
libsrtp2-1 \
libtcl8.6 \
libvorbis0a \
libtk8.6 \
libv4l-0 \
libva-drm2 \
libva-glx2 \
libva-wayland2 \
libva-x11-2 \
libva2 \
libvpx7 \
libyaml-0-2 \
libx264-164 \
libx265-199 \
libxml2 \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install some tools
COPY --link ./scripts/install_viu.sh /install_viu.sh
RUN ./install_viu.sh && rm /install_viu.sh
COPY --link ./scripts/install_gping.sh /install_gping.sh
RUN ./install_gping.sh && rm /install_gping.sh
COPY --link ./scripts/install_simple_http_server.sh /install_simple_http_server.sh
RUN ./install_simple_http_server.sh && rm /install_simple_http_server.sh
# Install Pre-built GStreamer
COPY --from=gstreamer /artifacts/. /.
# Update links for the installed libraries and check if GStreamer is setup correctly
COPY --link ./scripts/inspect_gst_plugins.sh /inspect_gst_plugins.sh
RUN ldconfig \
&& /inspect_gst_plugins.sh \
&& mkdir -p /home/pi/tools \
&& mv /inspect_gst_plugins.sh /home/pi/tools/.