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

build: devcontainer support #2179

Merged
merged 7 commits into from
Sep 28, 2024
Merged

build: devcontainer support #2179

merged 7 commits into from
Sep 28, 2024

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented Sep 27, 2024

Issue being fixed or feature implemented

To speed up development, new devs onboarding, integration with GitHub Codespaces and Copilot Workspace we want to define a devcontainer for platform developers https://containers.dev

What was done?

  • Define Initial devcontainer

How Has This Been Tested?

  • Build a dev container with RustRover and VS Code.
  • Use container with VS Code
  • Compile project with yarn build
  • Run JS tests
  • Run Rust tests

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a development container configuration for enhanced Rust development.
    • Added support for Protocol Buffers and WebAssembly tools in the development environment.
    • Included essential extensions for Visual Studio Code to improve developer experience.
    • Configured utilities and tools for better integration with the development environment.
  • Chores

    • Set up a Dockerfile with necessary dependencies for building and running Rust applications.

@shumkov shumkov added this to the v1.4.0 milestone Sep 27, 2024
Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The changes introduce a new Dockerfile and a configuration file for a development container tailored for the Dash Platform project. The Dockerfile sets up an environment based on the official VS Code Rust image, installing essential dependencies and tools, including Protocol Buffers and the wasm-bindgen-cli tool. The accompanying devcontainer.json file specifies the container's configuration, including extensions for Visual Studio Code and integrations for Git, Rust, Node.js, and more.

Changes

File(s) Change Summary
.devcontainer/Dockerfile Introduced a Dockerfile that sets up a Rust development environment with necessary dependencies and tools, including Protocol Buffers and wasm-bindgen-cli.
.devcontainer/devcontainer.json Created a configuration file defining the development container settings, including VS Code extensions and integrations for various tools.

Poem

In a container snug and bright,
Rust tools ready, what a sight! 🐰
Protocols and bindings in play,
Coding magic every day.
With VS Code, we hop and cheer,
A developer's dream is finally here! 🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f6cecda and bad1bfe.

📒 Files selected for processing (1)
  • .devcontainer/devcontainer.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .devcontainer/devcontainer.json

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (5)
.devcontainer/Dockerfile (4)

1-2: Good choice of base image, consider using a more specific tag.

The selection of the official VS Code dev container image for Rust is appropriate and aligns well with the PR objectives. It provides a solid foundation for Rust development in a containerized environment.

Consider using a more specific tag for the base image to ensure better reproducibility. For example, you could use a tag that includes the patch version:

- FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
+ FROM mcr.microsoft.com/devcontainers/rust:1-1-1-bullseye

This change would pin the image to a specific patch version, reducing the risk of unexpected changes in future builds.


4-16: Good dependency selection, consider improving cache handling.

The list of installed dependencies is comprehensive and appropriate for a Rust development environment. Combining apt-get update and apt-get install in a single RUN instruction is a good practice for reducing image layers.

To prevent issues with outdated package cache, consider adding apt-get clean and removing the apt lists. This will reduce the image size and ensure fresh package information in future builds. Here's a suggested modification:

 RUN apt-get update && apt-get install -y \
     build-essential \
     libssl-dev \
     pkg-config \
     clang \
     cmake \
     llvm \
     curl \
     gnupg \
     lsb-release \
     software-properties-common \
-    unzip
+    unzip \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/*

This change ensures that the package cache doesn't persist in the image, potentially causing issues with future package installations.


18-21: Protoc installation looks good, consider adding integrity verification.

The installation of Protoc is straightforward and uses a pinned version, which is excellent for reproducibility. The cleanup of the zip file after extraction is a good practice for keeping the image size down.

To enhance security, consider adding a step to verify the integrity of the downloaded Protoc file. You can do this by checking the SHA-256 hash of the file against the official hash provided by the Protobuf releases page. Here's an example of how you could modify the installation:

+ ARG PROTOC_SHA256=2497d8e22854d9f5ecf9e8f5a70eed7d75b3e6f5a2a0b20b50c44d8c8e7fb6e9
 RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-x86_64.zip \
+    && echo "${PROTOC_SHA256} protoc-25.2-linux-x86_64.zip" | sha256sum -c - \
     && unzip protoc-25.2-linux-x86_64.zip -d /usr/local \
     && rm protoc-25.2-linux-x86_64.zip

This change adds a verification step to ensure the integrity of the downloaded file before installation.


23-24: wasm-bindgen-cli installation is correct, consider optimizing.

The installation of wasm-bindgen-cli using Cargo is appropriate, and pinning the version ensures reproducibility.

To optimize the installation process and reduce the final image size, consider the following modifications:

  1. Use the --root option to install the binary to a specific directory.
  2. Only copy the binary to the final image location.
  3. Clean up the Cargo cache after installation.

Here's an example of how you could modify the installation:

- RUN cargo install [email protected]
+ RUN cargo install --root /tmp/wasm-bindgen [email protected] \
+     && cp /tmp/wasm-bindgen/bin/wasm-bindgen /usr/local/bin/ \
+     && rm -rf /tmp/wasm-bindgen \
+     && rm -rf $CARGO_HOME/registry

These changes will significantly reduce the size of the final image and speed up subsequent build steps.

.devcontainer/devcontainer.json (1)

7-20: Consider adding VS Code settings for improved developer experience.

The specified extensions are relevant and will enhance the development environment. However, the settings object is currently empty. Consider adding project-specific VS Code settings to further improve the developer experience and ensure consistency across the team.

You might want to add some common settings, for example:

"settings": {
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "rust-analyzer.checkOnSave.command": "clippy"
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 05b040f and 0d7317d.

📒 Files selected for processing (2)
  • .devcontainer/Dockerfile (1 hunks)
  • .devcontainer/devcontainer.json (1 hunks)
🔇 Additional comments (4)
.devcontainer/Dockerfile (1)

1-24: Overall, the Dockerfile is well-structured and achieves the PR objectives.

This Dockerfile successfully sets up a development environment for Rust with the necessary tools and libraries, including Protoc and wasm-bindgen-cli. It aligns well with the PR objectives of supporting devcontainers and improving the development experience.

The use of a specific base image, pinned versions for tools, and comprehensive dependency installation contributes to a reproducible and consistent development environment. This will greatly facilitate onboarding new developers and improve integration with tools like GitHub Codespaces and Copilot Workspace.

While the current implementation is functional, the suggested optimizations in the previous comments (if implemented) would further enhance the Dockerfile by:

  1. Improving reproducibility with more specific image tags
  2. Enhancing security through integrity checks
  3. Reducing the final image size
  4. Optimizing the build process

These improvements would result in a more efficient and secure development container, further supporting the goals of this pull request.

.devcontainer/devcontainer.json (3)

1-6: LGTM: Basic container configuration is well-defined.

The container name is descriptive, and the build configuration using a Dockerfile with the correct context is appropriate for customizing the development environment.


21-21: LGTM: Remote user configuration is appropriate.

Setting the remote user to "vscode" aligns with VS Code's defaults and is a good practice for dev containers.


22-35: Verify Rust version and Yarn installation decision.

The features configuration looks good overall and includes necessary tools for the project. However, there are two points to consider:

  1. Rust version 1.80 is specified, which is recent but not the latest stable version. Verify if this specific version is required or if you want to use the latest stable version.

  2. Yarn installation is explicitly disabled. Confirm if this is intentional, as Yarn is commonly used in Node.js projects for package management.

To check the latest stable Rust version, you can run:

#!/bin/bash
# Fetch the latest stable Rust version
curl -sSf https://static.rust-lang.org/releases.json | jq -r '.[] | select(.stable == true) | .version' | head -n1

To verify if Yarn is used in the project, you can search for Yarn-related files:

#!/bin/bash
# Check for Yarn-related files
fd -H '^yarn\.lock$|^\.yarnrc(\.yml)?$'

"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"postCreateCommand": "cargo install [email protected]"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Update wasm-bindgen-cli to the latest version (0.2.93)

The current postCreateCommand installs [email protected], while the latest available version is 0.2.93. Updating to the latest version can provide important bug fixes and improvements.

  • Recommendation: Update the version to 0.2.93 unless there are specific compatibility reasons to remain on 0.2.85.
🔗 Analysis chain

Verify if pinning wasm-bindgen-cli version is necessary.

Installing wasm-bindgen-cli is appropriate given the WebAssembly target in the Rust configuration. However, the version is pinned to 0.2.85.

Consider if this specific version is required for compatibility reasons. If not, you might want to allow for newer versions to benefit from bug fixes and improvements.

To check the latest version of wasm-bindgen-cli, you can run:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Fetch the latest version of wasm-bindgen-cli from crates.io
curl -s https://crates.io/api/v1/crates/wasm-bindgen-cli | jq -r '.crate.max_version'

Length of output: 169


Script:

#!/bin/bash
# Fetch the latest version of wasm-bindgen-cli from crates.io
curl -s https://crates.io/api/v1/crates/wasm-bindgen-cli | jq -r '.crate.max_version'

Length of output: 92

@shumkov shumkov merged commit 4ae1efd into v1.4-dev Sep 28, 2024
18 checks passed
@shumkov shumkov deleted the build/devcontainer branch September 28, 2024 07:28
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.

2 participants