Skip to content

[BREAKING] Add multi-project support via subdirectory mounting and compose overrides - #4

Merged
c-vigo merged 4 commits into
devfrom
c-vigo/issue3
Nov 26, 2025
Merged

c-vigo merged 4 commits into
devfrom
c-vigo/issue3

Conversation

@c-vigo

@c-vigo c-vigo commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

Description

This PR implements the ability to mount projects in subdirectories of /workspace instead of directly at /workspace. This enables multi-project development by allowing multiple repositories to be mounted simultaneously in a single devcontainer.

The implementation includes:

  • Project mounting to /workspace/<project_name> subdirectory structure
  • Docker Compose override support for mounting additional folders
  • Comprehensive documentation and examples
  • Full integration test coverage

Related Issue(s)

Closes #3

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates

Changes Made

Core Mount Structure Changes

  • Changed default project mount from /workspace to /workspace/<project_name> subdirectory
  • Updated workspaceFolder in devcontainer.json to /workspace/{{SHORT_NAME}}
  • Modified docker-compose.yml to use relative path (..) for project mounting
  • Updated postAttachCommand path to match new subdirectory structure
  • Adjust all initialization scripts (init-git.sh, init-precommit.sh, setup-git-conf.sh, post-attach.sh)

Environment Variable Cleanup

  • Removed redundant PYTHONUNBUFFERED and IN_CONTAINER from docker-compose.yml (inherited from base image)
  • Removed PRE_COMMIT_HOME from Containerfile (now project-specific, set in docker-compose.yml)
  • Added PROJECT_ROOT environment variable for script consistency

Docker Compose Override Support

  • Added .devcontainer/.gitignore to ignore user-specific override files
  • Created docker-compose.override.yml.example template with common mount patterns
  • Added comprehensive MOUNTS.md documentation (169 lines) covering:
    • Quick start guide
    • Mount patterns (sibling projects, home directory, absolute paths, read-only)
    • Troubleshooting and performance considerations
    • Real-world examples (monorepo, frontend+backend, reference docs)
  • Updated README.md with mounting section and quick start

Testing Infrastructure

  • Modified conftest.py fixture to test override functionality:
    • Creates test override file mounting tests directory
    • Updates devcontainer.json to include override (required for devcontainer CLI)
    • Proper cleanup after tests
  • Added TestDockerComposeOverride test class with 4 integration tests:
    • Directory existence verification
    • File accessibility checks
    • File reading operations
    • Directory listing and multiple file validation

Test Updates

  • Updated 15+ integration tests to expect subdirectory mount structure
  • Modified tests to check for relative path (..) in volumes
  • Updated all path references from /workspace to /workspace/test_project
  • Removed test_pre_commit_home_set from image tests (no longer in base image)
  • Added test for no redundant containerEnv in devcontainer.json

Testing

  • Tests pass locally (make test)
  • Image tests pass (make test-image)
  • Integration tests pass (make test-integration)
  • Registry tests pass (make test-registry) (if applicable)
  • Manual testing performed (describe below)

Manual Testing Details

  1. Subdirectory Mounting: Verified project mounts to /workspace/<project_name> correctly
  2. Override Functionality: Tested mounting additional folders using docker-compose.override.yml:
    • Mounted sibling project successfully
    • Verified file access and permissions
    • Confirmed directory listing works
  3. Script Execution: All initialization scripts (init-git.sh, init-precommit.sh, post-attach.sh) run without errors
  4. VS Code Integration: Dev Container opens to correct workspace folder
  5. Multi-project Setup: Successfully mounted and accessed multiple projects simultaneously

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (README.md, CONTRIBUTE.md, etc.)
  • I have updated the CHANGELOG.md in the [Unreleased] section
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Breaking Change Notice

This is a breaking change from any previous devcontainer setup (though no official release exists yet). Projects using the old structure will need to:

  1. Update their .devcontainer configuration with the new template
  2. Adjust any scripts referencing /workspace to use the new subdirectory structure

Key Implementation Details

Mount Resolution: The implementation uses .. (relative path) instead of ${localWorkspaceFolder} because:

  • The devcontainer CLI doesn't expand ${localWorkspaceFolder} correctly with podman-compose
  • Relative paths work consistently across Docker and Podman
  • The path is relative to the .devcontainer directory

Override File Handling: For the devcontainer CLI to use override files, they must be explicitly listed in devcontainer.json:
"dockerComposeFile": [
"docker-compose.yml",
"docker-compose.override.yml"
]VS Code's Dev Containers extension handles this automatically, but manual CLI usage requires explicit configuration.

Benefits

  • Enables multi-project development workflows
  • Better workspace organization
  • Supports monorepo and microservices architectures
  • Per-developer customization without git conflicts
  • Standard Docker Compose patterns
  • Comprehensive documentation and examples

- Add docker-compose.yml template with devcontainer service configuration
- Update devcontainer.json to use dockerComposeFile instead of direct image/mounts
- Move container configuration (image, volumes, environment) to docker-compose.yml
- Update TestDevContainerJson: remove image test, add dockerComposeFile and service tests
- Add TestDevContainerDockerCompose class with comprehensive docker-compose.yml tests
- update tests
- update setup script
Changed devcontainer to mount projects into /workspace/<project_name>
subdirectory rather than directly to /workspace.

Key changes:
- Set workspaceFolder to /workspace/{{SHORT_NAME}}
- Mount using relative path (..) to subdirectory in docker-compose volumes
- Update scripts path to match new structure
- Remove redundant env vars from docker-compose
- Remove PRE_COMMIT_HOME from base image (now project-specific)
- Update tests
Implements support for mounting additional folders using standard Docker
Compose override files. This enables e.g. multi-project development, shared
libraries, and reference material mounting without modifying committed
configuration.

New files:
- MOUNTS.md: Comprehensive documentation with examples
- docker-compose.override.yml.example: Template with common patterns
- .devcontainer/.gitignore: Ignores user-specific override files

Changes:
- README.md: Added mounting section with quick start
- conftest.py: Test fixture creates and tests override functionality
- test_integration.py: 4 integration tests verify mount operations

Features:
- Standard Docker Compose override pattern
- Per-developer customization (gitignored)
- Full integration test coverage
- Documentation with troubleshooting guide

Closes #3
@c-vigo c-vigo added this to the Initial release milestone Nov 26, 2025
@c-vigo c-vigo self-assigned this Nov 26, 2025
@c-vigo
c-vigo merged commit e762793 into dev Nov 26, 2025
@c-vigo
c-vigo deleted the c-vigo/issue3 branch November 26, 2025 16:15
@c-vigo c-vigo linked an issue Nov 26, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Mount project in a sub-folder /workspace/project_name

1 participant