In a development workflow that uses separate Dockerfiles for the project runtime and the devcontainer to manage the development dependencies, how are the Dockerfiles and devcontainers affected in the following scenarios?
- Code Changes Only: What happens to the Dockerfile and devcontainers if only the code changes (e.g., switching branches, modifying application code)?
- Environment or Dependency Changes: What happens to the Dockerfile and devcontainers if there are changes to the environment or dependencies (e.g., updating devcontainer.json, adding new dependencies to the project)?
Assumptions and Testing:
My assumption is that the development devcontainer does not need to be rebuilt for code changes because the code directory is usually mounted as a volume, allowing changes to be reflected immediately within the running devcontainer. To test this theory, I switched branches and made code changes (e.g., git checkout different-branch
), and observed that the changes were reflected immediately in the devcontainer.
However, in this scenario, I believe that the Docker image for the project runtime needs to be rebuilt to include the new code changes.
Is this assumption correct? If so, will the opposite be true for the second scenario? How can I test both scenarios to be sure?