Skip to content

Commit

Permalink
Add Dockerfile (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
YifuTao authored Sep 17, 2024
2 parents 2e0f478 + 353da89 commit e976db9
Showing 4 changed files with 129 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UID=1000
GID=1000
HOME_DIR=/home
SPIRES_DIR=${HOME_DIR}/oxford_spires_dataset
104 changes: 104 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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

##############
# 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 &&\
cd build &&\
cmake .. &&\
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 openmvs 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/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 ./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

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"]
21 changes: 21 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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
- ../tests:${SPIRES_DIR}/tests

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = [

0 comments on commit e976db9

Please sign in to comment.