-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
126 lines (115 loc) · 3.71 KB
/
Copy pathDockerfile
File metadata and controls
126 lines (115 loc) · 3.71 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
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
FROM rust:1.90-slim-bullseye
# Install cross-compilation tools and dependencies
RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
build-essential \
pkg-config \
libclang-dev \
clang \
cmake \
make \
libstdc++-10-dev:arm64 \
libc6-dev:arm64 \
curl \
wget \
unzip \
git \
# GStreamer and GLib development packages for aarch64
libgstreamer1.0-dev:arm64 \
libgstreamer-plugins-base1.0-dev:arm64 \
libglib2.0-dev:arm64 \
libcairo2-dev:arm64 \
libpango1.0-dev:arm64 \
libatk1.0-dev:arm64 \
libgdk-pixbuf2.0-dev:arm64 \
libgtk-3-dev:arm64 \
# GStreamer and GLib development packages for host (for examples)
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-libav \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-qt5 \
gstreamer1.0-pulseaudio \
libglib2.0-dev \
libcairo2-dev \
libpango1.0-dev \
libatk1.0-dev \
libgdk-pixbuf2.0-dev \
libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libatlas-base-dev \
gfortran
# Add QNN SDK for building with Qualcomm QNN support
# Either provide QNN_SDK_URL to download at build time, or mount the SDK via docker-compose
ARG QNN_SDK_VERSION=2.39.0.250926
ARG QNN_SDK_URL=""
RUN if [ -n "$QNN_SDK_URL" ]; then \
echo "Downloading QNN SDK from $QNN_SDK_URL..." && \
wget -q "$QNN_SDK_URL" -O /tmp/qnn-sdk.zip && \
unzip -q /tmp/qnn-sdk.zip -d /opt && \
rm /tmp/qnn-sdk.zip; \
else \
echo "No QNN_SDK_URL provided. Mount QNN SDK via docker-compose or set USE_QUALCOMM_QNN=0"; \
fi
ENV QNN_SDK_ROOT=/opt/qairt/${QNN_SDK_VERSION}
WORKDIR /app
# Install rustfmt for aarch64 target
RUN rustup target add aarch64-unknown-linux-gnu && \
rustup component add rustfmt
# Create symlinks to make cargo and rustc available in PATH
RUN ln -sf /usr/local/rustup/toolchains/*/bin/cargo /usr/local/bin/cargo && \
ln -sf /usr/local/rustup/toolchains/*/bin/rustc /usr/local/bin/rustc
# Git SSH configuration
RUN mkdir -p /root/.ssh && \
ssh-keyscan github.com >> /root/.ssh/known_hosts
# This is required to set the right permissions (600) for the SSH key
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Set up environment for cross-compilation
ENV TARGET_LINUX_AARCH64=1
ENV USE_FULL_TFLITE=1
ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
ENV CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
# Create a build script
RUN echo '#!/bin/bash\n\
set -e\n\
\n\
echo "Building for aarch64-unknown-linux-gnu..."\n\
\n\
# Set cross-compilation environment variables\n\
export TARGET_LINUX_AARCH64=1\n\
export USE_FULL_TFLITE=1\n\
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc\n\
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++\n\
\n\
# Build for aarch64 with FFI feature enabled\n\
cargo build --target aarch64-unknown-linux-gnu --features ffi --release\n\
\n\
# Build examples\n\
echo "Building examples..."\n\
cargo build --target aarch64-unknown-linux-gnu --features ffi --release --examples\n\
\n\
echo "Build completed successfully!"\n\
echo "Output files:"\n\
ls -la target/aarch64-unknown-linux-gnu/release/\n\
' > /usr/local/bin/build-aarch64.sh && chmod +x /usr/local/bin/build-aarch64.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# Default command
CMD ["/usr/local/bin/build-aarch64.sh"]