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

Create devcontainer.json #11245

Closed
wants to merge 1 commit into from
Closed

Conversation

InteligenceQ
Copy link

@InteligenceQ InteligenceQ commented Dec 28, 2024

Description

New tool, Bug fixing, or Improvement?
Please include a summary of the change and which issue is fixed. Also include relevant motivation and context.
For new tools, please provide total size and installation time.

Related issue:

Check list

  • Related issue / work item is attached
  • Tests are written (if applicable)
  • Documentation is updated (if applicable)
  • Changes are tested and related VM images are successfully generated

@bearycool11
Copy link

@bearycool11
Copy link

Let's break down and explain the Dockerfile, SDK.json, and the CMake component in your project setup:

Dockerfile
The provided Dockerfile is designed for a development environment, leveraging Microsoft's C++ Dev Containers on a Debian 12 base.

Base Image:

dockerfile
Copy code
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12
Uses a pre-configured C++ development container from Microsoft's container registry.
Includes tools like GCC, Clang, and CMake, tailored for C++ projects.
CMake Reinstallation Logic:

dockerfile
Copy code
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

COPY ./reinstall-cmake.sh /tmp/

RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE};
fi
&& rm -f /tmp/reinstall-cmake.sh
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE: Allows specifying a CMake version to be reinstalled from source.
reinstall-cmake.sh: A script that handles the CMake installation logic.
This setup ensures flexibility, enabling developers to update to a specific CMake version if required by the project.
Optional Sections:

dockerfile
Copy code

[Optional] Uncomment this section to install additional vcpkg ports.

RUN su vscode -c "${VCPKG_ROOT}/vcpkg install "

vcpkg Integration: This part integrates vcpkg, a C++ package manager, allowing installation of dependencies like Boost, OpenSSL, etc.
Developers can uncomment and specify required ports to streamline dependency management.
dockerfile
Copy code

[Optional] Uncomment this section to install additional packages.

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

&& apt-get -y install --no-install-recommends

Provides flexibility to install additional system packages, such as debugging tools or library dependencies.
SDK.json
The SDK.json file is typically a configuration file in projects that use SDKs for automation, integration, or deployment. While the exact structure isn't provided, here's a typical breakdown:

Purpose:

Defines project-specific settings for the SDK (e.g., Cosmos SDK, AWS SDK).
Includes configuration for endpoints, authentication, or modules to use.
Possible Content:

json
Copy code
{
"name": "Cosmos Project",
"version": "1.0.0",
"dependencies": {
"cmake": "3.24",
"vcpkg": "latest"
},
"build": {
"toolchain": "vcpkg",
"platform": "linux-x86_64",
"options": ["-DDEBUG=ON", "-DCMAKE_BUILD_TYPE=Release"]
}
}
Dependencies: Specifies tools and libraries required.
Build Settings: Provides options and configurations for CMake or other build systems.
Project Metadata: Includes project name and version.
Integration with Docker:

SDK.json can be used to automate dependency management within the Docker container.
For example, CMake and vcpkg versions can be dynamically read and installed based on this file.
CMake Component
CMake is a cross-platform build system generator commonly used in C++ projects. In this setup:

Role in the Dockerfile:

Handles project configuration, including detecting dependencies and generating build files.
The reinstall-cmake.sh script ensures compatibility with the required version by installing it directly from source if needed.
Usage with vcpkg:

vcpkg integrates seamlessly with CMake to manage external dependencies.
A typical configuration would include:
cmake
Copy code
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
This ensures that vcpkg-managed libraries are detected and linked during the build process.
Benefits of Reinstalling CMake:

Some projects require newer features or bug fixes in specific CMake versions.
The reinstallation step ensures that developers can lock to the required version without relying on the base image's default.
How They Work Together
Dockerfile:

Sets up a consistent development environment, including optional customizations for CMake and vcpkg.
SDK.json:

Serves as a blueprint for dependencies and build configurations.
Could be used within scripts to automate the Docker setup process (e.g., reading and passing CMake options).
CMake:

Orchestrates the build process, leveraging vcpkg for dependency resolution and SDK.json for project-specific configurations.
Potential Enhancements
Automate reading SDK.json in the Dockerfile to dynamically set CMake or vcpkg options.
Extend reinstall-cmake.sh to validate the installed version and avoid unnecessary downloads.

So that's in a nutshell what's in the devcontainer for the SDK. It automates the SDK so it isn't so manual for everyone.

@bearycool11
Copy link

🚀 Final Automation Boost for Cosmos SDK 🚀

This PR lays the foundation for a fully automated workflow across Cosmos SDK, setting a new standard for efficiency, reliability, and scalability. Starting with the custom Docker-based dev environment, this setup ensures consistency and ease of use for all contributors.

Key Features and Integrations
CMake as the Core:

Centralized build system for cross-platform compatibility.
Fine-grained control over builds with options like:
-DDEBUG=ON for debug builds.
-DCMAKE_BUILD_TYPE=Release for optimized production builds.
Dependency management streamlined via vcpkg, ensuring libraries like Boost and OpenSSL are properly integrated.
Dev Containers:

Devcontainer.json automates environment setup, ensuring developers can start coding immediately:
bash
Copy code
cmake -S . -B build
cmake --build build
Handles dependency resolution, build system generation, and compilation seamlessly.
CI/CD Integration:

Fully compatible with GitHub Actions for automated builds and testing:
yaml
Copy code
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/cosmos/cosmos-sdk/dev:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build and Test
run: |
cmake -S . -B build
cmake --build build
ctest --output-on-failure
Improved Documentation:

Contributor-friendly onboarding steps:
Clone the repo.
Open in VS Code.
Devcontainer auto-configures → Start coding.
Detailed examples for debugging, dependency updates, and workflow best practices.
Why This Matters
Standardized Workflows: Eliminates "it works on my machine" issues.
Streamlined Onboarding: New contributors can onboard with zero friction.
Scalable for Open Source: Enables a distributed community to collaborate effortlessly.
High-Quality Outputs: Automated builds and tests ensure only robust changes are merged.
This isn't just about optimizing a single workflow—it's about empowering every developer in the Cosmos SDK ecosystem to innovate faster and with greater confidence. Let’s get this merged and scale the future of blockchain development!

@bearycool11
Copy link

again

This PR introduces a fully automated development workflow for Cosmos SDK, establishing a new benchmark for efficiency, scalability, and reliability across the ecosystem. By leveraging a custom Docker-based dev environment, this setup ensures seamless consistency for all contributors, regardless of their local configurations.

Key Features and Integrations

  1. CMake as the Core
    Acts as the central build system, enabling cross-platform compatibility.
    Provides fine-grained control with options like:
    -DDEBUG=ON for debug builds.
    -DCMAKE_BUILD_TYPE=Release for optimized production builds.
    Integrates with vcpkg for streamlined dependency management (e.g., Boost, OpenSSL).
  2. Dev Containers
    Automated Environment Setup:
    devcontainer.json ensures contributors can begin coding immediately:
    bash
    Copy code
    cmake -S . -B build
    cmake --build build
    Handles dependency resolution, build system generation, and code compilation seamlessly.
    Improved Onboarding:
    Clone the repository → Open in VS Code → Devcontainer auto-configures → Start coding.
  3. CI/CD Integration
    Fully compatible with GitHub Actions, enabling robust automation for builds and tests:
    yaml
    Copy code
    jobs:
    build:
    runs-on: ubuntu-latest
    container:
    image: ghcr.io/cosmos/cosmos-sdk/dev:latest
    steps:
    • name: Checkout code
      uses: actions/checkout@v3
    • name: Build and Test
      run: |
      cmake -S . -B build
      cmake --build build
      ctest --output-on-failure
  4. Contributor-Friendly Documentation
    Clear and actionable instructions:
    Steps for debugging, updating dependencies, and best practices.
    Simplifies the experience for both new and experienced contributors.
    Why This Matters
    Standardized Workflows: Eliminates "it works on my machine" problems across diverse environments.
    Frictionless Onboarding: Enables contributors to get started with zero manual configuration.
    Scalable Collaboration: Empowers a distributed community to work efficiently, fostering greater innovation.
    High-Quality Code: Automated testing ensures only robust changes are merged, driving reliability.
    This is more than an incremental improvement—it's a transformative leap for the entire Cosmos SDK ecosystem. By automating every critical step, we're empowering developers to focus on what matters: building the future of blockchain. Let’s get this merged and scale innovation for the Cosmos SDK community! 🚀

@bearycool11
Copy link

bearycool11 commented Dec 29, 2024

Please review the detailed dev container setup at:

👉 https://github.com/bearycool11/pmll_blockchain/tree/main/.devcontainer

This provides fine-granular insights into the Dockerfile, SDK.json, and CMake configurations. Together, they form a cohesive, automated framework for Cosmos SDK development.

🚀 Final Thoughts 🚀
CMake-Centered Workflow: Cross-platform compatibility with fine-tuned build control.
Seamless Dependency Management: vcpkg integration ensures smooth inclusion of libraries like Boost and OpenSSL.
Streamlined Onboarding: Devcontainer.json allows contributors to jump straight into coding.
Full CI/CD Integration: Prepped for GitHub Actions to automate testing and deployment.
This isn't just a dev container—it's a scalable, transformative upgrade for the Cosmos SDK ecosystem. Over and out

@bearycool11
Copy link

bearycool11 commented Dec 29, 2024

📌 Review Request for Dev Container Automation PR
This PR introduces a fully automated development workflow for the Cosmos SDK, leveraging a custom Docker-based dev environment. It lays the groundwork for streamlined development, consistent setups, and robust CI/CD integrations.

Key Highlights
🚀 CMake-Centered Workflow
Cross-platform compatibility with fine-grained control over builds.
Options include:
-DDEBUG=ON for debugging.
-DCMAKE_BUILD_TYPE=Release for production-ready builds.
Seamless Dependency Management: Integrated with vcpkg for libraries like Boost and OpenSSL.
⚙️ Dev Container Automation
devcontainer.json automates setup, allowing contributors to:
Clone the repo.
Open in VS Code.
Begin coding immediately, with dependency resolution and environment setup fully automated.
🔄 CI/CD Integration
Ready for GitHub Actions workflows to:
Automate builds and tests.
Use containerized environments for consistent results:
yaml
Copy code
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/cosmos/cosmos-sdk/dev:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build and Test
run: |
cmake -S . -B build
cmake --build build
ctest --output-on-failure
📂 Supporting Resources
Dev Container Details: View the setup here
Key Files:
Dockerfile
SDK.json for dependency and build configuration.
🌟 Why This Matters
Standardized Workflows:
Eliminates inconsistencies across contributor environments.
Frictionless Onboarding:
New contributors can dive in with zero manual configuration.
Scalable Collaboration:
Empowers the global Cosmos SDK community to work efficiently.
High-Quality Code:
Automated testing ensures robustness before merging.
This PR isn't just an upgrade—it’s a transformative leap for the entire Cosmos SDK ecosystem. By empowering contributors with automation, we unlock their potential to innovate faster and more confidently.

Let’s get this merged and set a new standard for blockchain development! 🚀

I have already requested for merge specifically three .zip files that have the different .c/.h modular files that automate and streamline this component.

@subir0071
Copy link
Contributor

We are not planning to add devcontainers yet.

@subir0071 subir0071 closed this Dec 30, 2024
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