Skip to content

Migrate to Devcontainers POC #371

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

Merged
merged 51 commits into from
Apr 15, 2025
Merged

Migrate to Devcontainers POC #371

merged 51 commits into from
Apr 15, 2025

Conversation

anataliocs
Copy link
Contributor

@anataliocs anataliocs commented Apr 1, 2025

What

Migrated to Devcontainers!

I documented the changes in devcontainer.md and gave an intro to devcontainers in general.

So there are 2 main ways to engage with devcontainers:

  1. Through a browser via the web VSCode interface of Codespaces
  2. On your local VS Code using the Devcontainer as a backend dev env

In addition:

  • You can stream logs remotely or tunnel into the devcontainer with SSH(Not turned on by default currently)
  • Deep Github integration of course with copilot and access to workflows
  • Devcontainers also is compatible with a multitude of other providers. I added links for 2.
  • I also added instructions to launch codespaces with the Github CLI
  • Guided walkthrough for lauching Codespaces from VS Code
  • Walk through the Devcontainer, features, config and design choices

ADDED: Github Actions CI Pipeline Workflows

  • Verify JSON Schema of Devcontainers config
  • Unit test and lint bash config scripts
  • Use Devcontainer CLI to build
  • Make changes less brittle and detect breaking changes to config as early as possible

DX:

  • Included a script to build locally and jumpstart the pre-builds and caching loop
  • Stellar CLI with autocomplete, sccache, Rust and all the goodness and the make all script should be working
  • Added some customization to the terminal and IDE to make it feel more like home. Injected a bit of shell history and some VSCode settings

Why

Gitpod EOL and devcontainers are way better

Known limitations

  • Build is currently a little slow
  • TODO(Future PR) caching, prebuilds and optimization
  • make all fills up the 32GB disk so I may have to do some optimization there.
  • NOTE(prebuilds): Manual prebuild cache images are compatible with Github Prebuilds. GH Prebuilds are superior but the manual prebuilds are usable locally and also help speed up the GH Prebuild process for codespaces.

HOW

Testing steps
https://codespaces.new/stellar/soroban-examples/tree/migrate-to-devcontainers-poc

Make sure branch migrate-to-devcontainers-poc is chosen
image

cd to desired contract -> make all(build -> test)

cd account
make all

Or:

stellar contract build --manifest-path $CODESPACE_VSCODE_FOLDER/alloc/Cargo.toml

Test cache:

sccache --show-stat

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻 Few comments inline.

…o/.cargo/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/munki:/Users/chris.anatalio/.cargo/bin:/Users/chris.anatalio/Library/Application Support/JetBrains/Toolbox/scripts:/Users/chris.anatalio/.rvm/bin
@leighmcculloch
Copy link
Member

If you prefer to do it this way, I think it's reasonable to add the prebuilds in a follow up so that this can get merged and in use. Even if it's a bit slower to boot.

…o/.cargo/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/munki:/Users/chris.anatalio/.cargo/bin:/Users/chris.anatalio/Library/Application Support/JetBrains/Toolbox/scripts:/Users/chris.anatalio/.rvm/bin
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
@anataliocs
Copy link
Contributor Author

anataliocs commented Apr 7, 2025

ADDED Devcontainer GH Actions

  • validate-devcontainer-json.yml: Validates Devcontainer JSON Schema
  • build-and-test-devcontainer.yml Validates bash scripts and tests build with devcontainer with CLI

Only runs on changes to /.devcontainer

@anataliocs
Copy link
Contributor Author

  = note: /usr/bin/ld: final link failed: No space left on device
          collect2: error: ld returned 1 exit status

One issue I noticed is that make all fills up a 32GB disk so I may have to do some optimization there.

@anataliocs
Copy link
Contributor Author

Based on the provided diff for the devcontainer.json file, here are a few observations and potential issues to consider:

Port Forwarding:

Ensure that port 8000 is necessary and correctly configured for the intended use within your devcontainer. Avoid conflicts with other services using the same port.
Environment Variables:

The environment variables STELLAR_RPC_URL and STELLAR_NETWORK_PASSPHRASE are defined correctly. Make sure these values are correct and secure.
Features Configuration:

The features common-utils:2.5.3 and rust:1.3.1 are defined and configured properly. Ensure that these versions are suitable for your project requirements.
Commands:

The postCreateCommand, postStartCommand, postAttachCommand, initializeCommand, onCreateCommand, and updateContentCommand fields are defined correctly. Ensure that the referenced scripts (.devcontainer/post_start_cli_autocomplete.sh and .devcontainer/post_attach_welcome_text.sh) exist and are executable.
Syntax:

The JSON syntax is correct, and trailing commas have been removed where necessary.
If you need further analysis or specific checks, please let me know!

Reviewed devcontainers setup with Copilot ✅

@anataliocs
Copy link
Contributor Author

Tested:

cd account
make all
stellar contract build
ℹ️  CARGO_BUILD_RUSTFLAGS=--remap-path-prefix=/usr/local/cargo/registry/src= cargo rustc --manifest-path=Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release

Output ✅

    Finished `test` profile [unoptimized + debuginfo] target(s) in 1m 28s
     Running unittests src/lib.rs (target/debug/deps/soroban_account_contract-af22d991a97b8bca)

running 1 test
test test::test_token_auth ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
@anataliocs anataliocs self-assigned this Apr 7, 2025
anataliocs and others added 6 commits April 7, 2025 15:29
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Build stellar cli and sccache from gh release binary

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Build stellar cli and sccache from gh release binary

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Build stellar cli and sccache from gh release binary

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Build stellar cli and sccache from gh release binary

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Fix bash script tests

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Improve schema validation error msgs

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>

Cleanup

Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
Signed-off-by: chris.anatalio <chris.anatalio@stellar.org>
Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
@anataliocs anataliocs requested review from carstenjacobsen and removed request for janewang April 15, 2025 19:17
…soroban-examples into migrate-to-devcontainers-poc
Signed-off-by: Chris.Anatalio <chris.anatalio@stellar.org>
Signed-off-by: Chris.Anatalio <chris.anatalio@stellar.org>
@anataliocs anataliocs removed the request for review from ElliotFriend April 15, 2025 22:17
@anataliocs anataliocs merged commit 75f1cc6 into main Apr 15, 2025
101 checks passed
@anataliocs anataliocs deleted the migrate-to-devcontainers-poc branch April 15, 2025 22:45
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