forked from f1xpl/aasdk
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathDockerfile
More file actions
129 lines (116 loc) · 4.62 KB
/
Dockerfile
File metadata and controls
129 lines (116 loc) · 4.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
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
# * Project: OpenAuto
# * This file is part of openauto project.
# * Copyright (C) 2025 OpenCarDev Team
# *
# * openauto is free software: you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
# *
# * openauto is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with openauto. If not, see <http://www.gnu.org/licenses/>.
# Multi-stage build for AASDK with native compilation for each architecture
# This Dockerfile builds AASDK natively on each target platform using QEMU emulation
# Allow selecting Debian base (bookworm or trixie). Default to trixie.
ARG DEBIAN_VERSION=trixie
FROM debian:${DEBIAN_VERSION}-slim
# Build arguments
ARG TARGET_ARCH=amd64
ARG BUILD_TYPE=release
ARG RUN_TESTS=false
ARG DEBIAN_FRONTEND=noninteractive
ARG GIT_COMMIT_ID=unknown
ARG GIT_BRANCH=unknown
ARG GIT_DESCRIBE=unknown
ARG GIT_COMMIT_TIMESTAMP=unknown
ARG GIT_DIRTY=unknown
# Export git info as environment variables
ENV GIT_COMMIT_ID=${GIT_COMMIT_ID}
ENV GIT_BRANCH=${GIT_BRANCH}
ENV GIT_DESCRIBE=${GIT_DESCRIBE}
ENV GIT_COMMIT_TIMESTAMP=${GIT_COMMIT_TIMESTAMP}
ENV GIT_DIRTY=${GIT_DIRTY}
# Debug: Print git variables
RUN echo "Docker build args received:" && \
echo " GIT_COMMIT_ID=${GIT_COMMIT_ID}" && \
echo " GIT_BRANCH=${GIT_BRANCH}" && \
echo " GIT_DESCRIBE=${GIT_DESCRIBE}" && \
echo " GIT_COMMIT_TIMESTAMP=${GIT_COMMIT_TIMESTAMP}" && \
echo " GIT_DIRTY=${GIT_DIRTY}"
# Set locale to avoid encoding issues
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
# Install build dependencies and tools
RUN apt-get update && apt-get install -y \
# Core build tools
build-essential \
cmake \
ninja-build \
pkg-config \
git \
lsb-release \
# Development libraries (native for this platform)
libboost-all-dev \
libprotobuf-dev \
protobuf-compiler \
libusb-1.0-0-dev \
libssl-dev \
# Packaging tools
file \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /src
# Copy source code.
COPY . .
# Debug: List what was copied
RUN echo "Contents of /src:" && ls -la
# Create output directory for packages
RUN mkdir -p /output
# Make build script executable and verify it exists
RUN if [ -f "build.sh" ]; then \
echo "Found build.sh, making executable"; \
chmod +x build.sh; \
else \
echo "ERROR: build.sh not found!"; \
echo "Current directory contents:"; \
ls -la; \
exit 1; \
fi
# Build and package AASDK using the simplified build.sh approach
ARG CROSS_COMPILE=false
RUN echo "=== Git environment variables before build ===" && \
echo " GIT_COMMIT_ID=$GIT_COMMIT_ID" && \
echo " GIT_BRANCH=$GIT_BRANCH" && \
echo " GIT_DESCRIBE=$GIT_DESCRIBE" && \
echo " GIT_COMMIT_TIMESTAMP=$GIT_COMMIT_TIMESTAMP" && \
echo " GIT_DIRTY=$GIT_DIRTY" && \
echo " RUN_TESTS=$RUN_TESTS" && \
echo "=============================================" && \
export TARGET_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH) && \
TEST_ARG="" && \
if [ "$RUN_TESTS" = "true" ]; then TEST_ARG="test"; fi && \
echo "Building AASDK for architecture: $TARGET_ARCH (native compilation)" && \
# Compute distro-specific release suffix for DEB packages
DISTRO_DEB_RELEASE=$(bash /src/scripts/distro_release.sh) && \
CPACK_DEB_RELEASE="$DISTRO_DEB_RELEASE" && \
echo "Using CPACK_DEBIAN_PACKAGE_RELEASE: $CPACK_DEB_RELEASE" && \
# Pass through to CMake via build.sh using CMAKE_ARGS
env DISTRO_DEB_RELEASE="$CPACK_DEB_RELEASE" CMAKE_ARGS="$CMAKE_ARGS -DCPACK_DEBIAN_PACKAGE_RELEASE=$CPACK_DEB_RELEASE -DCPACK_PROJECT_CONFIG_FILE=/src/cmake_modules/CPackProjectConfig.cmake" \
CROSS_COMPILE=${CROSS_COMPILE} \
./build.sh ${BUILD_TYPE} clean ${TEST_ARG} package --skip-protobuf --skip-absl && \
if [ -d "packages" ]; then \
cp packages/*.deb /output/ 2>/dev/null || true && \
echo "Packages built:" && \
ls -la /output/; \
else \
echo "No packages directory found" && \
find . -name "*.deb" -exec cp {} /output/ \; 2>/dev/null || true; \
fi && \
echo "Build completed"# Default command
CMD ["bash", "-c", "echo 'AASDK build container ready. Use docker run with volume mounts to build packages.'"]