-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.cross
61 lines (57 loc) · 2.06 KB
/
Dockerfile.cross
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
ARG TARGET_PLATFORM=arm64
FROM --platform=${TARGET_PLATFORM} debian:bullseye-slim AS sysroot
ARG TARGET_PLATFORM
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update \
&& apt install -y \
libqt5websockets5-dev libqt5serialbus5-dev libqt5serialport5-dev \
libqt5sql5-mysql libqt5sql5-odbc libqt5sql5-psql libqt5sql5-sqlite \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
CMD [ "/usr/bin/bash" ]
FROM debian:bullseye-slim AS builder
ARG TARGET_PLATFORM
ENV DEBIAN_FRONTEND=noninteractive
RUN case "${TARGET_PLATFORM}" in \
'arm64') \
export ctoolchain=gcc-aarch64-linux-gnu; \
export cpptoolchain=g++-aarch64-linux-gnu ;; \
*) echo >&2 "unsupported platform: ${TARGET_PLATFORM}" ;exit 1 ;; \
esac; \
apt update \
&& apt install -y qtbase5-dev-tools git cmake ninja-build $ctoolchain $cpptoolchain \
&& rm -rf /var/lib/apt/lists/*
COPY --from=sysroot /lib /sysroot/lib
COPY --from=sysroot /usr/lib /sysroot/usr/lib
COPY --from=sysroot /usr/bin /sysroot/usr/bin
COPY --from=sysroot /usr/include /sysroot/usr/include/
COPY . /src
WORKDIR /src
RUN apt update && apt install -y file
RUN set -eux; \
case "${TARGET_PLATFORM}" in \
'arm64') \
export libs_arch="aarch64-linux-gnu"; \
export tool_prefix="aarch64-linux-gnu-"; \
# cross-kostyl
cp -RLf /usr/lib/qt5/bin/ /sysroot/usr/lib/qt5/; \
;; \
*) ;; \
esac; \
cmake \
-D CMAKE_SYSROOT=/sysroot \
-D CMAKE_SYSTEM_NAME=Linux \
-D CMAKE_FIND_ROOT_PATH=/sysroot \
-D CMAKE_C_COMPILER=${tool_prefix}gcc \
-D CMAKE_CXX_COMPILER=${tool_prefix}g++ \
-D CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-D CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-D CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-G Ninja -B /build
RUN cmake --build /build -j$(nproc)
FROM --platform=${TARGET_PLATFORM} debian:bullseye-slim AS runner
ARG TARGET_PLATFORM
COPY --from=sysroot /lib /lib
COPY --from=sysroot /usr/lib /usr/lib
COPY --from=builder /build/bin/radapter /radapter
ENTRYPOINT [ "/radapter" ]