forked from eclipse-velocitas/vehicle-app-cpp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.quick
More file actions
131 lines (104 loc) · 4.81 KB
/
Dockerfile.quick
File metadata and controls
131 lines (104 loc) · 4.81 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
130
131
# ============================================================================
# Dockerfile.quick - Mode 2 Blackbox Utility Container
# ============================================================================
# Purpose: Lightweight container for quick VehicleApp.cpp build and validation
# Usage:
# docker build -f Dockerfile.quick -t velocitas-quick .
# cat VehicleApp.cpp | docker run -i velocitas-quick
# ============================================================================
FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/cpp:v0.4
# Container metadata
LABEL maintainer="Velocitas Team"
LABEL description="Quick Build Utility for VehicleApp.cpp - Mode 2 Blackbox"
LABEL version="1.0"
# Environment configuration
ENV DEBIAN_FRONTEND=noninteractive
#ENV GITHUB_API_TOKEN=""
ENV SDV_MIDDLEWARE_TYPE=native
ENV SDV_VEHICLEDATABROKER_ADDRESS=127.0.0.1:55555
ENV SDV_MQTT_ADDRESS=127.0.0.1:1883
# User configuration
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create user (if not exists)
RUN groupadd --gid $USER_GID $USERNAME || true && \
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME || true
# Install essential packages for quick builds
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
sudo \
build-essential \
cmake \
ninja-build \
ccache \
pkg-config \
python3 \
python3-pip \
netcat-openbsd \
jq \
&& rm -rf /var/lib/apt/lists/*
# Configure sudo access
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Set up quick build workspace with proper ownership
RUN mkdir -p /quickbuild && chown -R $USERNAME:$USERNAME /quickbuild
# Switch to user context
USER $USERNAME
# Install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN python3 -m pip install --user --upgrade pip && \
python3 -m pip install --user -r /tmp/requirements.txt
# Set working directory
WORKDIR /quickbuild
# Copy fixed template configuration files
COPY --chown=$USERNAME:$USERNAME templates/AppManifest.json /quickbuild/app/AppManifest.json
COPY --chown=$USERNAME:$USERNAME templates/conanfile.txt /quickbuild/conanfile.txt
COPY --chown=$USERNAME:$USERNAME templates/CMakeLists.txt /quickbuild/CMakeLists.txt
COPY --chown=$USERNAME:$USERNAME templates/app/ /quickbuild/app/
# Copy template placeholder for VehicleApp.cpp
COPY --chown=$USERNAME:$USERNAME templates/app/src/VehicleApp.template.cpp /quickbuild/app/src/VehicleApp.cpp
# Copy minimal Velocitas configuration
COPY --chown=$USERNAME:$USERNAME .velocitas.json /quickbuild/.velocitas.json
# Initialize Velocitas environment
RUN pip install --user -r /tmp/requirements.txt && \
export PATH="$HOME/.local/bin:$PATH" && \
velocitas init -f -v
# Pre-install dependencies for faster builds
RUN export PATH="$HOME/.local/bin:$PATH" && \
velocitas exec build-system install
# Pre-generate vehicle model for faster builds
RUN export PATH="$HOME/.local/bin:$PATH" && \
velocitas exec vehicle-signal-interface download-vspec && \
velocitas exec vehicle-signal-interface generate-model
# Pre-build the template application for instant rerun
RUN export PATH="$HOME/.local/bin:$PATH" && \
velocitas exec build-system build -r
# Switch back to root for script installation
USER root
# Install utility scripts
COPY --chown=$USERNAME:$USERNAME scripts/ /scripts/
RUN chmod +x /scripts/*.sh
# Create CLI command aliases for quick access
RUN echo '#!/bin/bash\nexport PATH="$HOME/.local/bin:$PATH"\n/scripts/quick-build.sh "$@"' > /usr/local/bin/build && \
echo '#!/bin/bash\nexport PATH="$HOME/.local/bin:$PATH"\n/scripts/quick-run.sh "$@"' > /usr/local/bin/run && \
echo '#!/bin/bash\nexport PATH="$HOME/.local/bin:$PATH"\n/scripts/validate-template.sh "$@"' > /usr/local/bin/validate && \
echo '#!/bin/bash\nexport PATH="$HOME/.local/bin:$PATH"\n/scripts/quick-build.sh gen-model "$@"' > /usr/local/bin/gen-model && \
echo '#!/bin/bash\nexport PATH="$HOME/.local/bin:$PATH"\n/scripts/quick-build.sh compile "$@"' > /usr/local/bin/compile && \
echo '#!/bin/bash\nexport PATH="$HOME/.local/bin:$PATH"\n/scripts/quick-build.sh finalize "$@"' > /usr/local/bin/finalize && \
chmod +x /usr/local/bin/build /usr/local/bin/run /usr/local/bin/validate /usr/local/bin/gen-model /usr/local/bin/compile /usr/local/bin/finalize
# Switch back to user
USER $USERNAME
# Set up PATH for Velocitas tools
ENV PATH="/home/$USERNAME/.local/bin:$PATH"
# Expose common ports (optional - for future service integration)
EXPOSE 1883 55555 8080
# Health check for container readiness
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD /scripts/quick-build.sh help >/dev/null 2>&1 || exit 1
# Default entrypoint - quick build mode
ENTRYPOINT ["/scripts/quick-build.sh"]
# Default command - build action
CMD ["build"]