From 22e05d15f29689c011fec75c0dbe4a62ebcddc38 Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 11:46:56 +0100 Subject: [PATCH 1/7] feat: add docker files --- .docker/.env | 4 +++ .docker/Dockerfile | 59 ++++++++++++++++++++++++++++++++++++++ .docker/docker-compose.yml | 20 +++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 .docker/.env create mode 100644 .docker/Dockerfile create mode 100644 .docker/docker-compose.yml diff --git a/.docker/.env b/.docker/.env new file mode 100644 index 0000000..9e42d4a --- /dev/null +++ b/.docker/.env @@ -0,0 +1,4 @@ +UID=1000 +GID=1000 +HOME_DIR=/home +SPIRES_DIR=${HOME_DIR}/oxford_spires_dataset diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..b7c4bec --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,59 @@ +ARG UBUNTU_VERSION=22.04 +ARG NVIDIA_CUDA_VERSION=11.8.0 + +############## +# Base image # +############## +FROM nvidia/cuda:${NVIDIA_CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION} as base + +ARG ROS_DISTRO=noetic +ARG COLMAP_VERSION=3.8 +ARG CUDA_ARCHITECTURES=native +ARG HOME_DIR=/home + +SHELL ["/bin/bash", "-c"] + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + curl \ + git \ + python-is-python3 \ + python3.10-dev \ + python3-pip \ + vim \ + wget && \ + rm -rf /var/lib/apt/lists/* + + RUN python -m pip install --no-cache-dir --upgrade pip setuptools pathtools promise pybind11 + +#################### +# Deployment image # +#################### +FROM base as deploy + +ARG GID +ARG UID +ENV UNAME=docker_dev +RUN addgroup --gid $GID $UNAME +RUN adduser --disabled-password --gecos '' --uid $UID --gid $GID $UNAME + +ARG SPIRES_DIR=/home/docker_dev/oxford_spires_dataset +WORKDIR ${SPIRES_DIR} + +COPY ./requirements.txt ${SPIRES_DIR}/requirements.txt +RUN pip install -r requirements.txt +COPY ./oxford_spires_utils/ ${SPIRES_DIR}/oxford_spires_utils/ +COPY ./pyproject.toml ${SPIRES_DIR}/pyproject.toml +RUN pip install -e . + +# Make the outputs of the container match the host + +RUN chown -R ${UID}:${GID} ${SPIRES_DIR}/* +USER ${UNAME} +RUN echo "PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@docker-\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '" >> ~/.bashrc + +CMD ["/bin/bash"] \ No newline at end of file diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml new file mode 100644 index 0000000..6e07400 --- /dev/null +++ b/.docker/docker-compose.yml @@ -0,0 +1,20 @@ +services: + spires: + container_name: spires_container + build: + context: .. + dockerfile: .docker/Dockerfile + target: deploy + args: + - USERNAME=${USER:-user} + - UID=${UID} + - GID=${GID} + environment: + - NVIDIA_VISIBLE_DEVICES=all + - NVIDIA_DRIVER_CAPABILITIES=all + runtime: nvidia + network_mode: "host" + tty: true + volumes: + - ../scripts:${SPIRES_DIR}/scripts + From 9ff8798b6eb2f46ae0b53f41cece452c854cec9c Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 16:03:40 +0100 Subject: [PATCH 2/7] refactor: remove readme from pyproject so that no readme is needed when installing --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2c75c66..9a5568e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,6 @@ build-backend = "setuptools.build_meta" name = "oxford_spires_utils" version = "0.0.1" description = "Utility functions for the Oxford Spires Dataset." -readme = "README.md" # license = { text="Apache 2.0"} requires-python = ">=3.8.0" classifiers = [ From 6a37e63d1a8a4478fe6e556c469237e8f64d539b Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 16:03:59 +0100 Subject: [PATCH 3/7] feat: add spires_cpp dependencies to docker --- .docker/Dockerfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index b7c4bec..c00224f 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -30,6 +30,21 @@ RUN apt-get update && \ RUN python -m pip install --no-cache-dir --upgrade pip setuptools pathtools promise pybind11 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libeigen3-dev \ + libpcl-dev &&\ + rm -rf /var/lib/apt/lists/* + +RUN git clone https://github.com/OctoMap/octomap.git --branch v1.10.0 ${HOME_DIR}/octomap &&\ + cd ${HOME_DIR}/octomap &&\ + mkdir build &&\ + cd build &&\ + cmake .. &&\ + make &&\ + make install + #################### # Deployment image # #################### @@ -47,7 +62,9 @@ WORKDIR ${SPIRES_DIR} COPY ./requirements.txt ${SPIRES_DIR}/requirements.txt RUN pip install -r requirements.txt COPY ./oxford_spires_utils/ ${SPIRES_DIR}/oxford_spires_utils/ +COPY ./spires_cpp ${SPIRES_DIR}/spires_cpp/ COPY ./pyproject.toml ${SPIRES_DIR}/pyproject.toml +RUN cd ${SPIRES_DIR}/spires_cpp && pip install -e . RUN pip install -e . # Make the outputs of the container match the host From 9b8a5aa1c46cb8ffc4265552307a6135dbc3e4e7 Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 16:05:01 +0100 Subject: [PATCH 4/7] refactor: format Docker file --- .docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c00224f..c73a414 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -28,7 +28,7 @@ RUN apt-get update && \ wget && \ rm -rf /var/lib/apt/lists/* - RUN python -m pip install --no-cache-dir --upgrade pip setuptools pathtools promise pybind11 +RUN python -m pip install --no-cache-dir --upgrade pip setuptools pathtools promise pybind11 RUN apt-get update && \ From 340a7b13c71e3bf0834fc57ab54731191ff205d2 Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 16:17:19 +0100 Subject: [PATCH 5/7] fix: redefine spires_dir --- .docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index c73a414..bc1dbf2 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -56,7 +56,7 @@ ENV UNAME=docker_dev RUN addgroup --gid $GID $UNAME RUN adduser --disabled-password --gecos '' --uid $UID --gid $GID $UNAME -ARG SPIRES_DIR=/home/docker_dev/oxford_spires_dataset +ARG SPIRES_DIR=/home/oxford_spires_dataset WORKDIR ${SPIRES_DIR} COPY ./requirements.txt ${SPIRES_DIR}/requirements.txt From d93306d7f2d66443cc1837ae69e4c5369b26293a Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 16:17:38 +0100 Subject: [PATCH 6/7] refactor: add tests to docker as volumes --- .docker/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 6e07400..5235c79 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -17,4 +17,5 @@ services: tty: true volumes: - ../scripts:${SPIRES_DIR}/scripts + - ../tests:${SPIRES_DIR}/tests From 353da8940014f0412cb426686323cd2f7923d0d8 Mon Sep 17 00:00:00 2001 From: Yifu Tao Date: Tue, 17 Sep 2024 17:11:02 +0100 Subject: [PATCH 7/7] feat: add openmvs build --- .docker/Dockerfile | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index bc1dbf2..59f49d8 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -30,13 +30,17 @@ RUN apt-get update && \ RUN python -m pip install --no-cache-dir --upgrade pip setuptools pathtools promise pybind11 - +############## +# spires_cpp # +############## +from base as spires_cpp RUN apt-get update && \ apt-get install -y --no-install-recommends \ libeigen3-dev \ libpcl-dev &&\ rm -rf /var/lib/apt/lists/* +# Octomap RUN git clone https://github.com/OctoMap/octomap.git --branch v1.10.0 ${HOME_DIR}/octomap &&\ cd ${HOME_DIR}/octomap &&\ mkdir build &&\ @@ -45,10 +49,34 @@ RUN git clone https://github.com/OctoMap/octomap.git --branch v1.10.0 ${HOME_DIR make &&\ make install +############## +# OpenMVS # +############## +from spires_cpp as openmvs +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + # Boost + libboost-iostreams-dev libboost-program-options-dev libboost-system-dev libboost-serialization-dev \ + # OpenCV + libopencv-dev \ + # CGAL + libcgal-dev libcgal-qt5-dev &&\ + rm -rf /var/lib/apt/lists/* + +ARG OPENMVS_BUILD_ARG="-DOpenMVS_USE_CUDA=ON -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs/ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ -DCUDA_INCLUDE_DIRS=/usr/local/cuda/include/ -DCUDA_CUDART_LIBRARY=/usr/local/cuda/lib64 -DCUDA_NVCC_EXECUTABLE=/usr/local/cuda/bin/" +RUN git clone https://github.com/cdcseacave/VCG.git ${HOME_DIR}/vcglib &&\ + git clone --recurse-submodules https://github.com/cdcseacave/openMVS.git ${HOME_DIR}/openMVS &&\ + cd ${HOME_DIR}/openMVS &&\ + mkdir make &&\ + cd make &&\ + cmake .. -DCMAKE_BUILD_TYPE=Release -DVCG_ROOT=${HOME_DIR}/vcglib $OPENMVS_BUILD_ARG &&\ + make &&\ + make install + #################### # Deployment image # #################### -FROM base as deploy +FROM openmvs as deploy ARG GID ARG UID