This repository (LCAS/CMP9767) serves as the image builder repository for creating standardized development container images used by students in robotics courses. It implements an automated build pipeline that creates ready-to-use development environments containing all necessary ROS2 packages, dependencies, and tools.
├── src/ # Source packages to be included in the container
│ └── cmp9767_tutorial/ # Course-specific ROS2 packages
├── config/ # Configuration files
├── maps/ # Map files for navigation
├── params/ # Parameter files
└── worlds/ # Simulation world files
├── .devcontainer/ # Container build configuration
│ ├── devcontainer.json # Dev container settings for this repo
│ ├── Dockerfile # Multi-stage build instructions
│ └── post-create.sh # Container initialization script
└── .github/workflows/ # Automated build pipelines
├── container-build.yml # Main image build workflow
└── dev-container.yml # CI validation workflow
Add packages to the src/ directory:
- Your own packages: Create ROS2 packages directly in
src/with properpackage.xmlfiles (e.g. usingros2 pkg create) - External packages: Add as git submodules to integrate other repositories
- Dependencies: List all ROS dependencies in
package.xmlfiles - they will be automatically installed
Example structure:
src/
├── cmp9767_tutorial/ # Main course package
│ ├── package.xml # Dependencies declared here
│ ├── setup.py # Python package setup
│ └── cmp9767_tutorial/ # Python modules
└── external_package/ # Git submodule (optional)
└── package.xml
The build system uses a multi-stage Dockerfile approach:
# Copies only package.xml files to analyze dependencies
COPY ./src/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
COPY ./src/*/*/package.xml /tmp/src/_workspace/src/_pkgs_xmls
# ... (handles nested package structures)# Installs all ROS dependencies using rosdep
RUN rosdep install --from-paths /tmp/src --ignore-src -y# Copies full source code and builds all packages
COPY ./src /opt/ros/lcas/src/workspace/src
RUN cd /opt/ros/lcas && colcon buildThe container-build.yml workflow:
- Triggers on pushes to
mainbranch and version tags - Builds multi-architecture images (AMD64, ARM64)
- Publishes to
lcas.lincoln.ac.uk/lcas/cmp9767 - Uses layer caching for faster builds
Key workflow features:
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=lcas.lincoln.ac.uk/cache/lcas/cmp9767:latest
tags: |
type=raw,value=staging
type=ref,event=branch
type=semver,pattern={{version}}Students are recommended to use a separate template repository (e.g. like cmp3103-ws) that:
- Does NOT contain a Dockerfile (no local building)
- References the pre-built image from this repository
- Provides a clean workspace for student development
student-workspace/
├── .devcontainer/
│ ├── devcontainer.json # Points to pre-built image (very much similar to this repo's devcontainer.json, but with `image` instead of `build)
│ └── post-create.sh # Student-specific setup (usually copy from the post-create.sh above)
├── src/ # Student's ROS2 packages
└── README.md # Development instructions
{
"name": "Student Development Environment",
"image": "lcas.lincoln.ac.uk/lcas/cmp9767:latest",
"forwardPorts": [5801],
"portsAttributes": {
"5801": {
"label": "desktop",
"onAutoForward": "openBrowser"
}
},
"postStartCommand": "/opt/entrypoint.sh /bin/true; .devcontainer/post-create.sh",
"remoteUser": "ros",
"updateRemoteUserUID": true,
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-vscode.cpptools",
"JaehyunShim.vscode-ros2",
"nonanonno.vscode-ros2",
"deitry.colcon-helper"
]
}
}
}-
Add/Update Packages:
# Add your package to src/ cd src/ ros2 pkg create my_new_package --build-type ament_python # Or add external package as submodule git submodule add https://github.com/user/ros2-package.git src/external_package
-
Update Dependencies:
- Edit
package.xmlfiles to declare all ROS dependencies - The build system automatically installs them via
rosdep
- Edit
-
Test Locally:
# Build and test in this repository's devcontainer colcon build --symlink-install -
Publish:
- Push to
mainbranch → triggers automatic build - Create version tag → creates versioned image
git tag v1.2.3 git push origin v1.2.3
- Push to
- Create Repository: Use template repository to create private workspace
- Clone and Open: Clone in VS Code and "Reopen in Container"
- Develop: Add packages to
src/, build withcolcon build - Access Tools: Use virtual desktop (port 5801) for GUI applications
- Latest:
lcas.lincoln.ac.uk/lcas/cmp9767:latest - Versioned:
lcas.lincoln.ac.uk/lcas/cmp9767:1.0.0 - Branch:
lcas.lincoln.ac.uk/lcas/cmp9767:main
{
"image": "lcas.lincoln.ac.uk/lcas/cmp9767:latest"
}- No manual Dockerfile editing required for new ROS packages
- rosdep integration installs all declared dependencies
- Multi-level package detection supports nested package structures
- Multi-stage builds minimize final image size
- Layer caching speeds up subsequent builds
- Dependency pre-installation reduces student setup time
- Virtual desktop with 3D acceleration support
- Pre-configured VS Code extensions for ROS2 development
- Automatic workspace building on container startup
- Port forwarding for web-based interfaces
- Build failures: Check
package.xmldependencies are correctly declared - Missing packages: Ensure packages are properly placed in
src/withpackage.xml - Permission issues: Verify
updateRemoteUserUID: truein student devcontainer.json
- Check GitHub Actions logs in the repository
- Test locally using this repository's devcontainer
- Verify rosdep can resolve all dependencies
- Keep this repository clean: Only include essential course packages
- Use semantic versioning: Tag releases for stable environments
- Test before publishing: Use staging builds for validation
- Document changes: Update this file when adding new packages
- Minimize dependencies: Only add what students actually need
To migrate from local Dockerfile builds to this system:
- Move packages: Copy ROS2 packages to this repository's
src/ - Update student repos: Replace Dockerfile with image reference
- Version control: Tag this repository for stable releases
- Update documentation: Point students to new template repository
This system provides a scalable, maintainable approach to managing development environments for robotics education, separating the complexity of image building from student development workflows.