Skip to content

Commit 29bf3ec

Browse files
authored
Update Dockerfile to avoid the additional clone (#45)
* Update Dockerfile to avoid the additional clone Signed-off-by: Roumen Guha <roumen.guha@gmail.com> * Update requirements.txt * Fixed lots of bugs Signed-off-by: Roumen Guha <roumen.guha@gmail.com> --------- Signed-off-by: Roumen Guha <roumen.guha@gmail.com>
1 parent 11a11b7 commit 29bf3ec

29 files changed

+178
-152
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Makefile
66

77
.vscode**
88

9-
python_venv/**
109
.idea/**
1110
.venv/**
1211
__pycache__

CMakeLists.txt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,24 @@ include(CMakePackageConfigHelpers)
1515
# Custom modules and scripts
1616
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
1717
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
18-
include(opencv)
19-
include(pcl)
20-
include(eigen)
21-
include(ceres)
22-
include(gtsam)
23-
include(pangolin)
24-
include(utils)
25-
#include(...)
18+
include(find_eigen3)
19+
include(find_opencv)
20+
include(find_ceres)
21+
include(find_pcl)
22+
include(find_gtsam)
23+
include(find_spdlog)
24+
include(find_pangolin)
2625

27-
set(CMAKE_CXX_STANDARD 17)
26+
message("Generated with build type: ${CMAKE_BUILD_TYPE}, config types: ${CMAKE_CONFIGURATION_TYPES}")
2827
message(STATUS "-std=C++17")
29-
28+
set(CMAKE_CXX_STANDARD 17)
3029
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
3130
set(CMAKE_CXX_FLAGS "-O0")
3231
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
3332
message(STATUS "-Wall -Wextra -O0")
3433

35-
# 3rdParty dependencies
36-
#add_subdirectory(third_party EXCLUDE_FROM_ALL)
34+
# 3rd party dependencies
35+
# add_subdirectory(thirdparty EXCLUDE_FROM_ALL)
3736

3837
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
3938

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM ubuntu:22.04
2+
3+
# ARG CUDA_ARCHITECTURES=native
4+
5+
# Prevent stop building ubuntu at time zone selection.
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
8+
# Prepare an empty machine for building.
9+
RUN apt-get update && \
10+
apt-get install -y \
11+
sudo \
12+
git \
13+
ccache \
14+
cmake \
15+
unzip \
16+
ninja-build \
17+
build-essential \
18+
gfortran \
19+
ripgrep \
20+
fd-find \
21+
python3 \
22+
python3-pip \
23+
intel-mkl \
24+
libatlas-base-dev \
25+
liblapack-dev \
26+
libblas-dev
27+
28+
# Install python dependencies for build_dependencies.py
29+
RUN pip3 install --upgrade pip
30+
RUN pip3 install gitpython pyyaml
31+
32+
## For AMD CPUs using intel-mkl
33+
ENV MKL_DEBUG_CPU_TYPE=5
34+
35+
## Copy repo to container, then build dependencies
36+
COPY . /cpp-cv-project/
37+
WORKDIR /cpp-cv-project/
38+
RUN chmod +x build_dependencies.py && \
39+
./build_dependencies.py --d
40+
41+
# Build the main project, check if dependencies are correctly installed
42+
RUN cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug
43+
RUN cmake --build ./build
44+
RUN ./build/bin/solution
45+
46+
# Provide folders for mounting data and documents
47+
WORKDIR /
48+
RUN mkdir -p /Documents/ /data/
49+
CMD ["/bin/bash"]

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,23 @@ Status legend:
4040

4141
>You need [Python3](https://www.python.org/) to use the automation scripts for project setup and build.
4242
43+
### Docker (Ubuntu)
44+
45+
Build an image:
46+
```commandline
47+
docker build . --tag cpp_cv_project:latest
48+
```
49+
50+
Assuming your code lives in ~/Documents, you can start your container like so:
51+
```commandline
52+
docker run -p 8080:80 -it -v ${HOME}/Documents/:/Documents/ cpp_cv_project
53+
```
54+
4355
### Linux
4456

4557
```bash
4658
# Install Python 3 and required modules
47-
sudo apt install python3 python3-pip
59+
sudo apt-get install python3 python3-pip
4860
pip3 install pyyaml gitpython
4961

5062
# Edit `setup_config.yaml` to configure project
@@ -69,7 +81,7 @@ gedit ./thirdparty/packages.yaml
6981

7082
## License :bank:
7183

72-
This repo is licensed under MIT license. Click [here]([./LICENSE](https://github.com/changh95/cpp-cv-project-template/blob/main/LICENSE)) to view the license.
84+
This repo is licensed under MIT license. Click [here](https://github.com/changh95/cpp-cv-project-template/blob/develop/LICENSE) to view the license.
7385

7486
## Contributors :sunglasses:
7587

build_dependencies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def main():
5858
if args.j != 0:
5959
cfg.basic_config.nproc = " -j" + str(args.j)
6060

61-
#install_apt_packages(cfg)
62-
#install_libraries_from_source(cfg)
61+
install_apt_packages(cfg)
62+
install_libraries_from_source(cfg)
6363
install_python_packages(cfg)
6464

6565

cmake/ceres.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Ceres-solver
22

3-
find_package (Ceres PATHS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/ceres-solver/install)
3+
message(STATUS "Finding Ceres... checking ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ceres/install")
4+
find_package (Ceres PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/ceres/install)
45
if (${Ceres_FOUND})
5-
message(STATUS "Found Ceres-solver")
6+
message(STATUS "Found Ceres")
67
add_definitions(-DCERES_DEVELOP)
78

89
include_directories(
@@ -12,5 +13,5 @@ if (${Ceres_FOUND})
1213
set(CERES_LIBS Ceres::ceres)
1314

1415
else (${Ceres_FOUND})
15-
message(STATUS "Could not support Ceres-solver")
16+
message(STATUS "Could not support Ceres")
1617
endif (${Ceres_FOUND})

cmake/find_gtsam.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
message(STATUS "Finding GTSAM...")
2+
3+
if (CMAKE_BUILD_TYPE MATCHES "Debug")
4+
find_package(GTSAM REQUIRED HINTS ${CMAKE_SOURCE_DIR}/thirdparty/gtsam/install/Debug/lib/cmake)
5+
endif (CMAKE_BUILD_TYPE MATCHES "Debug")
6+
7+
if (CMAKE_BUILD_TYPE MATCHES "Release")
8+
find_package(GTSAM REQUIRED HINTS ${CMAKE_SOURCE_DIR}/thirdparty/gtsam/install/Release/lib/cmake)
9+
endif (CMAKE_BUILD_TYPE MATCHES "Release")
10+
11+
if(${GTSAM_FOUND})
12+
message(STATUS "Found: GTSAM - ${GTSAM_INCLUDE_DIRS}")
13+
14+
include_directories(${GTSAM_INCLUDE_DIRS})
15+
set(GTSAM_LIBS gtsam)
16+
endif(${GTSAM_FOUND})

cmake/find_pcl.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
message(STATUS "Finding PCL...")
2+
3+
if (CMAKE_BUILD_TYPE MATCHES "Debug")
4+
set(EIGEN_ROOT ${CMAKE_SOURCE_DIR}/thirdparty/eigen/install/Debug)
5+
find_package(Eigen3 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen/install/Debug/share/eigen3/cmake)
6+
find_package(PCL REQUIRED HINTS ${CMAKE_SOURCE_DIR}/thirdparty/pcl/install/Debug/share/pcl-1.13/)
7+
endif (CMAKE_BUILD_TYPE MATCHES "Debug")
8+
9+
if (CMAKE_BUILD_TYPE MATCHES "Release")
10+
set(EIGEN_ROOT ${CMAKE_SOURCE_DIR}/thirdparty/eigen/install/Release)
11+
find_package(Eigen3 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/eigen/install/Release/share/eigen3/cmake)
12+
find_package(PCL REQUIRED HINTS ${CMAKE_SOURCE_DIR}/thirdparty/pcl/install/Release/share/pcl-1.13/)
13+
endif (CMAKE_BUILD_TYPE MATCHES "Release")
14+
15+
if(${PCL_FOUND})
16+
message(STATUS "Found: PCL - ${PCL_INCLUDE_DIRS}")
17+
include_directories(${PCL_INCLUDE_DIRS})
18+
set(PCL_LIBS ${PCL_LIBRARIES})
19+
endif(${PCL_FOUND})

cmake/find_spdlog.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
message(STATUS "Finding spdlog...")
22

3+
# csv reader dependency
4+
set(THREADS_PREFER_PTHREAD_FLAG ON)
5+
find_package(Threads REQUIRED)
6+
set(THREAD_LIBS Threads::Threads)
7+
38
find_package(spdlog CONFIG REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/spdlog/install/Release/lib/cmake/spdlog)
49

510
if(spdlog_FOUND)
611
message(STATUS "Found Spdlog - ${spdlog_INCLUDE_DIRS}")
712

813
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/spdlog/install/Release/include)
914

10-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/spdlog/install/Release/include)
1115
set(SPDLOG_LIBS spdlog::spdlog)
1216

1317
endif(spdlog_FOUND)

cmake/gtsam.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GTSAM
22

3-
find_package (GTSAM PATHS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/GTSAM/install)
3+
find_package (GTSAM PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gtsam/install)
44
if (${GTSAM_FOUND})
55
message(STATUS "Found GTSAM")
66
add_definitions(-DGTSAM_DEVELOP)

0 commit comments

Comments
 (0)