-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devcontainer for development environment #7763
base: develop
Are you sure you want to change the base?
Devcontainer for development environment #7763
Conversation
…s to fix ownership issues of files mounted - especially in windows, it does not recognize the workspace as a git repository
…pt cvat_server - cvat_server container shall be removed by vscode, so avoid clash of processes
…le docker compose down - add a volume for saving container user data between builds
- refactor env vars defaults
…at_server. - This is done because devcontainer uses `devcontainer` user instead of `django` user and it mounts the workspace to `/home/devcontainer/workspace` instead of `/home/devcontainer` to avoid devcontainer processes pollute the workspace files
…ner image - Add comments regarding ownership issues of volume mount directories
WalkthroughThis update brings significant enhancements to CVAT's development environment by introducing a structured setup within a development container. It streamlines the development process, integrates essential tools, and optimizes configurations for efficient development workflows. Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 17
Out of diff range and nitpick comments (5)
.devcontainer/docker-compose.yml (3)
8-12
: Clarify the purpose of thepull
argument in the build context.The
pull
argument is used in the build context, but its purpose is not immediately clear. Consider adding a comment to explain why it is necessary to fetch upstream base image changes on container rebuild.
24-33
: Ensure volume mappings do not cause performance issues.The use of named volumes for static files and node_modules is intended to improve write performance on non-Linux machines. Monitor the performance to ensure that these settings do not inadvertently cause slowdowns or other issues in different environments.
85-85
: Document the use of git branch values in volume names.The use of git branch values to parameterize volume names is a clever way to isolate the development environment. Consider adding documentation or comments in the file to explain this setup to new developers.
.devcontainer/init.sh (1)
74-86
: Document the manual merging of Docker Compose files.The script manually merges Docker Compose files due to limitations in VS Code Remote. Consider documenting this workaround both in the script and in the project documentation to inform other developers.
site/content/en/docs/contributing/running-tests.md (1)
147-151
: Update the documentation to reflect the non-requirement of certain steps in devcontainer.The documentation mentions that building the CVAT server image and running the cvat_opa container are not required for devcontainer. Consider highlighting or separating these instructions more clearly to avoid confusion among developers using devcontainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
Out of diff range and nitpick comments (3)
.devcontainer/init.sh (1)
39-41
: The command substitution indocker inspect
should handle potential errors more gracefully to avoid script failure.Consider checking the exit status of the
docker inspect
command explicitly and handle the error scenario appropriately.site/content/en/docs/contributing/running-tests.md (1)
56-57
: Clarify the activation instructions for thetest-venv
virtual environment to ensure users can easily follow the steps.Consider adding a more explicit command or script snippet that shows how to activate the environment before executing the code.
site/content/en/docs/contributing/development-environment.md (1)
Line range hint
206-206
: Change "need install" to "need to install" to correct the grammatical structure.- you may need install `hdf5` + you may need to install `hdf5`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Out of diff range and nitpick comments (1)
.devcontainer/postcreate.sh (1)
24-24
: Consider the security implications of marking all directories as git safe globally.Using
git config --global --add safe.directory '*'
marks all directories as safe, which can potentially expose the system to malicious repositories. It's safer to specify directories explicitly or use a more restrictive setting.
Correct grammatical mistakes in the documentation Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied PR review suggestions from CodeRabbit Bot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
…tcreate command GitHub codespaces takes long time on chown
…e to postcreate command" This reverts commit 4e64aef.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- site/content/en/docs/contributing/running-tests.md (5 hunks)
Additional Context Used
LanguageTool (4)
site/content/en/docs/contributing/running-tests.md (4)
Near line 50: ‘necessary requirements’ might be wordy. Consider a shorter alternative.
Context: ...dcvat-cli
source code 1. Install all necessary requirements before running REST API tests: ``` ...
Near line 107: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...ST API tests: Attach to RQ lowfor the low priority queue worker -
REST API tests: Attach ...
Near line 175: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...sts` when using dev container 1. If you want to debug particular tests then change the ...
Near line 175: Possible missing comma found.
Context: ...iner 1. If you want to debug particular tests then change the configuration of the co...
Additional comments not posted (4)
site/content/en/docs/contributing/running-tests.md (4)
59-59
: This clarification is helpful for users in a devcontainer environment.
147-147
: Correctly noted as unnecessary in the devcontainer setup.
151-151
: Correctly noted as unnecessary in the devcontainer setup.
174-174
: Enhances the debugging experience by providing specific instructions for devcontainer environments.
Many new contributors face problems while setting up the development environment on their system. Devcontainers can simplify the process and save their valuable time. This pull request configures devcontainer for running cvat both on local system as well as on GitHub Codespaces.
Motivation and context
closes #6230
Guide from the documentation
Dependencies
sh
shell for running initial shell scriptsOptional steps
.env
file with the variables mentioned indist.env
file and modify their values.devcontainer/docker-compose.yml
.devcontainer
directory create a.env
file with variables mentioned indist.env
fileGIT_BRANCH_ISOLATION
environment variable is used at the build time of the dev container. It enables the persistence of container data between builds by using Docker volumes namespaced by the Git branch name. It is set to true by default. More details on this are provided in a later section.Local Dev-Container guide
Open Remote Window
and selectreopen in container
Initially it shall take some time to set up as it will build the dev container image and pull all the required docker images. Subsequent builds shall be fast and use cache to build and run the container
GitHub Codespaces guide
Open Remote Window
and selectcreate new codespace
Open Remote Window
menu, selectconnect to codespace
and select the codespace you created in the previous step amd the container shall start buildingRun and debug guide
Steps are common for both local and codespaces remote development
Run and Debug
panel in VS Code and launch the following configurations:It shall do the following operations:
.env
file or use the default values8080
for serving theopa
container7000
It shall do the following operations:
3000
This launch config is used to run and debug python unit tests for the django apps and
cvat-cli
.devcontainer: django
anddevcontainer: rq worker
,devcontainer: ui
panels in the debug console respectivelyserver
and uilaunch
configs, one should be able to log in to thecvat
website running on thelocalhost:3000
with username and password asadmin
Dev-Container Features
cvat/server:dev
Upon every rebuild, the dev container shall try to pull the latest base image and therefore it will always have the latest upstream changes without any user interventiondevcontainer.json
filetesting.txt
requirements file which inheritsdevelopment
,production
anddataset_manifest
requirements filespytest
. It can be activated by selecting/opt/venv-test/bin/python
in thePython: Select interpreter
command pallette menupostCreateCommand
specified indevcontainer.json
filedatumaro
, it clones the git repo every time the packages are updated; this takes a long time for the update to finish. To avoid this, its git commit_hash value from the base image is saved and used to check if an update is requiredzsh
devcontainer
and it is a non-root user; however, one can access the root user via sudo without any password to perform root operations like installing development-specific applications.devcontainer/Dockerfile
, and rebuild the containerpip install
. They shall not persist between container builds; therefore, it is just useful for testing new packages. They can be made to persist by adding them to the requirements file and rebuilding the imageuser.name
anduser.email
are already configured inside the containerSQLTool
extension is pre-configured for thecvat-db
databaseTerminal: Create New Integrated Terminal (Local)
from the command pallette. It can be used to run command on the host machine. It can be useful for accessingdocker
running on the host machinepytest
tests and debug it without disturbing the main development containers and its portsOPA
andnuctl
cli applications preinstalledLimitations
chown
on an existing directory in Dockerfile is very slow. So it shall take a while to build the container for the first timeHow has this been tested?
Manual testing on Linux and Windows machines, and GitHub Codespaces.
Checklist
develop
branch[ ] I have added tests to cover my changes[ ] I have increased versions of npm packages if it is necessary(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Chores
.gitignore
to include new development environment files and configurations.