Debian Codegraph @

docker/Dockerfile

raw
1 # syntax=docker/dockerfile:1
2
3 ARG UBUNTU_VERSION=24.04
4 ARG NVIDIA_CUDA_VERSION=12.9.1
5
6 #
7 # Docker builder stage.
8 #
9 FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} AS builder
10
11 ARG CUDA_ARCHITECTURES=all-major
12 ARG CCACHE_MAXSIZE=500M
13 ENV QT_XCB_GL_INTEGRATION=xcb_egl
14 ENV CCACHE_DIR=/colmap/build/.ccache
15 ENV CCACHE_BASEDIR=/colmap
16 ENV CCACHE_COMPILERCHECK=content
17 ENV CCACHE_MAXSIZE=${CCACHE_MAXSIZE}
18 ENV CCACHE_NOHASHDIR=true
19
20 # Prevent stop building ubuntu at time zone selection.
21 ENV DEBIAN_FRONTEND=noninteractive
22
23 # Prepare and empty machine for building.
24 RUN apt-get update && \
25 apt-get install -y \
26 ccache \
27 cmake \
28 ninja-build \
29 build-essential \
30 libboost-program-options-dev \
31 libboost-graph-dev \
32 libboost-system-dev \
33 libeigen3-dev \
34 libopenimageio-dev \
35 openimageio-tools \
36 libmetis-dev \
37 libgoogle-glog-dev \
38 libgtest-dev \
39 libgmock-dev \
40 libsqlite3-dev \
41 libglew-dev \
42 qt6-base-dev \
43 libqt6opengl6-dev \
44 libqt6openglwidgets6 \
45 qt6-svg-dev \
46 libcgal-dev \
47 libceres-dev \
48 libcurl4-openssl-dev \
49 libssl-dev \
50 libmkl-full-dev
51
52 # Fix issue in Ubuntu's openimageio CMake config.
53 # We don't depend on any of openimageio's OpenCV functionality,
54 # but it still requires the OpenCV include directory to exist.
55 RUN mkdir -p /usr/include/opencv4
56
57 # Copy source into the image.
58 COPY . /colmap
59
60 # Build and install COLMAP.
61 RUN cd /colmap && \
62 mkdir -p build/.ccache && \
63 ccache --zero-stats && \
64 cd build && \
65 cmake .. \
66 -GNinja \
67 -DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
68 -DCMAKE_INSTALL_PREFIX=/colmap-install \
69 -DBLA_VENDOR=Intel10_64lp && \
70 ninja install
71
72 #
73 # Stage to export build caches for CI round-tripping via actions/cache.
74 #
75 FROM scratch AS cache-export
76 COPY --from=builder /colmap/build/.ccache/ /.ccache/
77
78 #
79 # Docker runtime stage.
80 #
81 FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION} AS runtime
82
83 # Minimal dependencies to run COLMAP binary compiled in the builder stage.
84 # Note: this reduces the size of the final image considerably, since all the
85 # build dependencies are not needed.
86 RUN apt-get update && \
87 apt-get install -y --no-install-recommends --no-install-suggests \
88 libboost-program-options1.83.0 \
89 libc6 \
90 libomp5 \
91 libopengl0 \
92 libmetis5 \
93 libceres4t64 \
94 libopenimageio2.4t64 \
95 libgcc-s1 \
96 libgl1 \
97 libglew2.2 \
98 libgoogle-glog0v6t64 \
99 libqt6core6 \
100 libqt6gui6 \
101 libqt6widgets6 \
102 libqt6openglwidgets6 \
103 libqt6svg6 \
104 libcurl4 \
105 libssl3t64 \
106 libmkl-locale \
107 libmkl-intel-lp64 \
108 libmkl-intel-thread \
109 libmkl-core && \
110 apt-get clean && \
111 rm -rf /var/lib/apt/lists/*
112
113 # Copy all files from /colmap-install/ in the builder stage to /usr/local/ in
114 # the runtime stage. This simulates installing COLMAP in the default location
115 # (/usr/local/), which simplifies environment variables. It also allows the user
116 # of this Docker image to use it as a base image for compiling against COLMAP as
117 # a library. For instance, CMake will be able to find COLMAP easily with the
118 # command: find_package(COLMAP REQUIRED).
119 COPY --from=builder /colmap-install/ /usr/local/