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

Enhance dev container #2226

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

klinkin
Copy link

@klinkin klinkin commented Jan 30, 2025

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (refactoring and improving code)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Description

This PR improves the Dev Container configuration and post-create.sh script to enhance reliability, maintainability, and developer experience.

Key Improvements

Dev Container Configuration (devcontainer.json)

  • Added postCreateCommand to automatically execute the enhanced post-create.sh script.
  • Ensured zsh is set as the default terminal profile in VS Code.
  • Improved the list of extensions to enhance productivity:
    • Added shellcheck, prettier, git-graph for better shell scripting, formatting, and Git visualization.
    • Refined settings for auto-saving files and formatting on save.

Post-Create Script (post-create.sh)

  • Fixed nvm availability issue by ensuring it is sourced properly before use.
  • Introduced idempotency by checking for existing dependencies before installing them.
  • Wrapped Zsh plugin installation in a function to reduce redundancy and improve maintainability.
  • Added informative logging using echo statements for better debugging and execution visibility.
  • Ensured better error handling by adding set -e to stop execution on failures.

Additional context

This update ensures a more robust and developer-friendly Dev Container setup by minimizing redundant installations, improving shell experience, and providing a more consistent development environment. 🚀

Mihail Klimin added 2 commits January 30, 2025 17:45
- Add error handling with 'set -e'
- Ensure Node.js version check before installation
- Improve idempotency for dependencies
- Add logging for script execution
- Introduce modular Zsh plugin installation
 - onCreateCommand: Added Git configuration for user name and email, which is a useful setup for contributors.
 - postCreateCommand: Added installation of jekyll and bundler gems, which are necessary for building Jekyll sites.

VSCode Settings:
 - files.autoSave: Configures auto-save behavior when the window focus changes.
 - editor.formatOnSave: Ensures code is automatically formatted when saving files.
 - workbench.colorTheme: Uses the "Dark+" theme for consistency with many developers' preferences.
 - ruby.rubyPath: Ensures Ruby tools work with the correct Ruby version.

Extensions:
 - Added Ruby and YAML extensions to support Jekyll and configuration files.
 - Added GitLens for enhanced Git experience, and Git Graph for visualization of Git repositories.
 - Integrated several tools such as ShellCheck and Prettier for better shell scripting and code formatting.
Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to improve the project! After reviewing your changes, I found that your modifications duplicate existing settings (such as zsh and vscode-plugins configurations, which are already set up in .vscode) and introduce some redundant environment checks (like nvm). Therefore, I am curious about the situations you encountered that made the original post-create.sh insufficient for initialization tasks?

"redhat.vscode-yaml",

// Enhanced Git functionality with GitLens for better repository insights
"eamodio.gitlens"
]

Choose a reason for hiding this comment

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

I believe these extensions could be a great addition to the config that's been updated. I find these tools helpful to me while writing blogs, from an end user perspective.

Suggested change
]
// Spelling Checker for blog writers
"streetsidesoftware.code-spell-checker",
// Grammar Checker for blog writers
"davidlday.languagetool-linter"
]

"workbench.colorTheme": "Dark+ (default dark)",

// Ruby path for proper integration with Ruby-based tools
"ruby.rubyPath": "/usr/local/bin/ruby"
},

Choose a reason for hiding this comment

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

I believe these extensions could be a great addition to the config that's been updated. I find these tools helpful to me while writing blogs, from an end user perspective.

If you're considering adding the previously mentioned changes, it might be better to add this config too... Using the public API enabled the Language-Tool extension to work properly.

Suggested change
},
// Using public API for language tools extension
"languageToolLinter.serviceType": "public"
},

@iamwatchdogs
Copy link

Thank you for taking the time to improve the project! After reviewing your changes, I found that your modifications duplicate existing settings (such as zsh and vscode-plugins configurations, which are already set up in .vscode) and introduce some redundant environment checks (like nvm). Therefore, I am curious about the situations you encountered that made the original post-create.sh insufficient for initialization tasks?

I doubt whether zsh is a valid option or not, I tried replacing it with bash and it worked out pretty fine and somehow the ohmyzsh changes were reflected when I reopen within the dev container using bash shell.

image

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