Skip to content

Commit d35c3b4

Browse files
gartneraclaude
andcommitted
feat(gpu): add ccache and layer splitting for faster builds
Port build speed improvements from PR OpenDroneMap#1959 to gpu.Dockerfile: - Add ccache (CC/CXX/CCACHE_DIR env vars + apt install) - Split COPY commands so system deps and SuperBuild compile layers are cached independently from application code changes - Use RUN --mount=type=cache for the cmake/make step - Copy docker/ early since PORTABLE_INSTALL needs the gcc/g++ wrappers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8e54843 commit d35c3b4

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

gpu.Dockerfile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,36 @@ FROM nvidia/cuda:12.9.1-devel-ubuntu24.04 AS builder
33
# Env variables
44
ENV DEBIAN_FRONTEND=noninteractive \
55
PYTHONPATH="$PYTHONPATH:/code/SuperBuild/install/local/lib/python3.12/dist-packages:/code/SuperBuild/install/lib/python3.12/dist-packages:/code/SuperBuild/install/bin/opensfm" \
6-
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/code/SuperBuild/install/lib"
6+
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/code/SuperBuild/install/lib" \
7+
CC="ccache gcc" \
8+
CXX="ccache g++" \
9+
CCACHE_DIR=/ccache
710

811
# Prepare directories
912
WORKDIR /code
1013

11-
# Copy everything
12-
COPY . ./
14+
RUN apt-get update && \
15+
apt-get install -y --no-install-recommends ccache && \
16+
apt-get clean && \
17+
rm -rf /var/lib/apt/lists/*
18+
19+
# Copy build prerequisites first for better layer caching
20+
COPY snap/ ./snap/
21+
COPY configure.sh ./
22+
COPY requirements.txt ./
23+
COPY docker/ ./docker/
24+
25+
# Install system dependencies
26+
RUN PORTABLE_INSTALL=YES GPU_INSTALL=YES bash configure.sh installreqs
1327

14-
# Run the build
15-
RUN PORTABLE_INSTALL=YES GPU_INSTALL=YES bash configure.sh install
28+
COPY SuperBuild/ ./SuperBuild/
29+
30+
# Compile SuperBuild with ccache
31+
RUN --mount=type=cache,target=/ccache \
32+
PORTABLE_INSTALL=YES GPU_INSTALL=YES bash configure.sh install
33+
34+
# Copy remaining source
35+
COPY . ./
1636

1737
# Run the tests
1838
ENV PATH="/code/venv/bin:$PATH"

0 commit comments

Comments
 (0)