build(docker): turn image into a dev environment with mounted sources
All checks were successful
Verification / Is-Buildable (push) Successful in 2m59s

This commit is contained in:
Artur Mukhamadiev 2026-09-14 11:51:29 +03:00
parent 1740f9d6fc
commit 2016b14f91
4 changed files with 59 additions and 38 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
build*/
datasets/
*.ply
*.tar.gz

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ large_tool_results/
# Point-cloud exports
*.ply
build-docker/

View File

@ -1,38 +1,39 @@
# Use Ubuntu 24.04 as base (matching development environment)
# Build-environment image: contains the toolchain and dependencies only.
# The source tree is bind-mounted at runtime and compiled inside the container:
#
# docker build -t cloud-point-rpc-dev .
# docker run -d --name cprpc-dev --network=host -v "$(pwd)":/app cloud-point-rpc-dev
# docker exec -it cprpc-dev meson setup build-docker
# docker exec -it cprpc-dev meson compile -C build-docker
# docker exec -it cprpc-dev ./build-docker/src/cloud_point_rpc_cli config.yml
#
# Use a dedicated build directory (build-docker) so host and container
# builds never share Meson state.
FROM ubuntu:24.04
# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
# - build-essential: Compiler (gcc/g++)
# - meson/ninja-build: Build system
# - git: For fetching subprojects
# - pkg-config, cmake: For dependency resolution
# - libssl-dev: Often needed for cmake fetches/networking
RUN apt-get update && apt-get install -y \
# - build-essential, meson, ninja-build, cmake, pkg-config: toolchain
# - git: Meson subprojects (asio, json, yaml-cpp, glog, jsonrpccxx, gtest)
# - libopencv-dev: OpenCV 4 incl. contrib modules (ximgproc for the WLS filter)
# - libunwind-dev: glog stack traces
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
meson \
ninja-build \
git \
pkg-config \
cmake \
pkg-config \
git \
ca-certificates \
libunwind-dev \
libopencv-dev \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
# The mounted checkout is usually owned by a different uid than root inside
# the container; git refuses to touch it otherwise (Meson subprojects need git).
RUN git config --global --add safe.directory '*'
WORKDIR /app
# Copy project files
COPY . .
# Setup build directory and compile
# We allow git to fetch subprojects (glog, gtest, asio, etc.)
RUN meson setup build && \
meson compile -C build
# Run the cli by default
# We assume the config.yaml is in the root /app or we copy it.
# The build output is in build/src/cloud_point_rpc_cli
CMD ["./build/src/cloud_point_rpc_cli", "config.yaml"]
# Keep the container alive; build and run via `docker exec`.
CMD ["tail", "-F", "/dev/null"]

View File

@ -20,10 +20,9 @@ Done:
- [x] Binary PLY export with grid triangulation and `ply_stride` decimation
- [x] Optional WLS / median disparity post-filters (`wls_filter`, `CpuStereoMatcher::Params`)
- [x] SCARED benchmark with ground-truth metrics, depth PNGs and `scripts/scared_overview.py`
- [x] Unity-side C# implementation per [docs/unity-integration.md](docs/unity-integration.md)
To do:
- [ ] Unity-side C# implementation per [docs/unity-integration.md](docs/unity-integration.md)
- [ ] Remove sliver triangles at the border of the valid region (long spikes are still visible in
shaded viewers at `ply_stride: 4` because 5 % of local depth allows 3 mm edges)
- [ ] Visually compare raw vs WLS meshes in a shaded web viewer and decide the visualisation default
@ -127,27 +126,43 @@ meson test -C build -v
## Docker
You can build and run the cli using `Docker`.
The `Dockerfile` builds a **development environment** image only: toolchain
(GCC, Meson, Ninja, CMake), git for the Meson subprojects and OpenCV 4 with
contrib modules. Nothing is compiled at image build time. The source tree is
bind-mounted into the running container and compiled there, so edits on the
host are picked up immediately and the build artefacts land in your checkout.
### 1. Build Image
### 1. Build the environment image
```bash
docker build -t cloud-point-rpc .
docker build -t cloud-point-rpc-dev .
```
### 2. Run Container
The cli will try to connect to a **running server** on ip and port defined in config.yml file. (defined in `config.yaml` inside the image).
For simplicity, it's better to use a host network, so you will not have any headache with accessability.
> _Server is not configured to run through container, if you need, contact me_
You also can mount your own `config.yaml` to override the default settings:
### 2. Start the container with the source mounted
```bash
docker run --network=host -it -v $(pwd)/my_config.yaml:/app/config.yaml cloud-point-rpc
docker run -d --name cprpc-dev --network=host -v "$(pwd)":/app cloud-point-rpc-dev
```
The container idles (`tail -F /dev/null`); `--network=host` lets the CLI
reach a server running on the host and lets the server be reached from Unity.
### 3. Build and run inside the container
```bash
docker exec -it cprpc-dev meson setup build-docker
docker exec -it cprpc-dev meson compile -C build-docker
docker exec -it cprpc-dev meson test -C build-docker
docker exec -it cprpc-dev ./build-docker/src/cloud_point_rpc_cli config.yml
```
Use a dedicated build directory such as `build-docker`: Meson stores absolute
compiler paths, so a build directory configured on the host cannot be reused
inside the container and vice versa. With rootless Docker the container's
root maps to your host user, so `build-docker/` stays owned by you; with a
rootful daemon add `--user "$(id -u):$(id -g)"` to `docker run` to avoid
root-owned build files.
## Validation with SCARED Dataset
The `scared_dataset_server` executable lets you validate the stereo point-cloud