-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
chore: ability to work with Blockscout code base within a VSCode devcontainer #10838
Conversation
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.
Let's also add a small instruction to CONTRIBUTING.md
on how to use this with Github codespaces for new contributors.
@k1rill-fedoseev please take a look one more time |
@k1rill-fedoseev I have added |
@@ -65,3 +65,4 @@ dump.rdb | |||
*.env.example | |||
*.env.local | |||
*.env.staging | |||
.devcontainer/.blockscout_config |
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.
Let's add .devcontainer/
to .dockerignore
too
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.
done in 410bb41
Resolves #10432
Motivation
Setting up a local development environment for Blockscout was time-consuming and error-prone, requiring manual installation of Elixir, Phoenix, Node.js, and other dependencies. To streamline this process, a pre-configured dev container using Docker was introduced. This containerized environment allows developers to work with the Blockscout codebase without needing to install and configure dependencies on their local machines. It also ensures consistency across development environments, reducing the risk of version conflicts and setup errors. Additionally, database management was simplified by including a PostgreSQL service, and essential VS Code extensions were integrated to enhance productivity. By using this dev container, contributors can get started more quickly, allowing them to focus on development rather than setup.
This feature also enables seamless development for Blockscout using GitHub Codespaces, allowing contributors to work directly in a cloud-based environment without the need to install or configure VS Code locally. By leveraging Codespaces, developers can instantly spin up a fully-configured dev environment, further reducing setup time and making it easier to contribute from any device.
Key features introduced by these changes include:
Pre-configured Development Environment: The
.devcontainer
directory provides a full development environment with Elixir, Phoenix, and Node.js pre-configured, automatically installs project dependencies, and includes scripts for common development tasks, further streamlining the setup and development process.Integrated PostgreSQL Database Service: The
docker-compose.yml
file sets up a PostgreSQL service alongside the Elixir application, simplifying database management and allowing immediate use with pre-defined environment settings.Port Forwarding for Local Access: Specific ports (4000, 4001, 5432) are forwarded through the container, enabling easy local access to the Blockscout application and database.
VS Code Customizations, Extensions, and Features: The
devcontainer.json
file integrates useful VS Code extensions and features for Blockscout development, including Elixir LS, GitHub Copilot, PostgreSQL tools and persistent shell history, enhancing developer productivity and experience in the containerized environment.Optional GitHub SSH Authorization: The
devcontainer.json
file includes a commented-out section that provides an optional configuration to mount SSH keys, allowing developers to authenticate and push changes to GitHub directly from within the dev container.Development Task Orchestration: A new
bs
script has been added to simplify common development tasks such as initializing the project, managing the database, and running the server.Changelog
Enhancements
devcontainer.json
:mix deps.get
, ensuring all project dependencies are installed automatically upon container creation.bin
directory in the PATH, making the development scripts easily accessible.shell-history
feature to provide persistent command history in the development container.docker-compose.yml
:postgres
), simplifying local database setup and integration.Development Scripts:
bs
script in.devcontainer/bin/
to orchestrate typical development tasks such as project initialization, database management, and server execution..devcontainer/bin/chain-specific-checks
to perform checks based on theCHAIN_TYPE
..devcontainer/bin/utils
for checking RPC endpoints availability and accessibility.Configuration:
.blockscout_config.example
file to provide a template for Blockscout configuration settings.Dockerfile
:Checklist for your Pull Request (PR)
master
in the Version column. If I removed variable, I added it to Deprecated ENV Variables page. After merging docs PR, changes will be reflected in these pages.