Skip to content
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

Add VS Code dev container configuration. #2857

Merged
merged 3 commits into from
Dec 20, 2023
Merged

Add VS Code dev container configuration. #2857

merged 3 commits into from
Dec 20, 2023

Conversation

smarnach
Copy link
Contributor

This PR adds a dev container configuration for VS Code. Features:

  • All dependencies are installed in the dev container, so IntelliSense fully works, and type checking will also work once we add type annotations.
  • Allows running the tests using VS Code's Python test browser, which makes running and debugging tests really convenient. (This is the main reason to use a container instead of a virtualenv in the first place.)
  • Sets up Black as the default Python formatter. We can consider adding a setting to automatically format Python code on save.

I'm not really an expert on VS Code, so it's possible there are better ways of setting this up. This configuration works well for me, though, and it might be useful for others as well.

@smarnach smarnach requested a review from a team as a code owner December 18, 2023 14:22
Copy link
Contributor

@biancadanforth biancadanforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Sven for these improvements! Like you, I am not a VS Code expert, but I agree this is a nice improvement for devs using VS Code.

I do have one request to add a small docs section for VS Code on using the Dev Containers extension. Perhaps we can add a .vscode/extensions.json file with a recommendations field pointing to the Dev Containers extension as well (referencing something similar I remember as a dev for FxA)?

.devcontainer/Dockerfile Show resolved Hide resolved
.devcontainer/Dockerfile Show resolved Hide resolved
.devcontainer/Dockerfile Show resolved Hide resolved
.devcontainer/devcontainer.json Show resolved Hide resolved
.devcontainer/docker-compose.yml Show resolved Hide resolved
@smarnach
Copy link
Contributor Author

@biancadanforth I added some documentation and the recommendation for the dev container extension. Please take another look.

Copy link
Contributor

@biancadanforth biancadanforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Made a couple of small suggestions on the docs. Thank you.

docs/dev.rst Show resolved Hide resolved
docs/dev.rst Show resolved Hide resolved
@smarnach
Copy link
Contributor Author

I found a bug in the configuration. Since the devcontainer service inherits from the test service, it also inherits the image name tecken:build from that service. As a result, building the dev container overrides the tag for the Tecken image, and if you stop and restart the whole stack, the dev container is used for any service inheriting from base. I fixed this by using a different image name for the dev conatiner.

@smarnach smarnach merged commit b6e6ca2 into main Dec 20, 2023
1 check passed
@smarnach smarnach deleted the devcontainer-config branch December 20, 2023 16:04
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.

3 participants