-
Notifications
You must be signed in to change notification settings - Fork 82
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
Changes from 39 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
8d1319f
Initial Devcontainers config
anataliocs fb4c43f
Update config
anataliocs e68310c
Update startup scripts
anataliocs c021c4f
Update devcontainer for stellar cli
anataliocs f0ace8e
Add cargo watch binaryen and make all entrypoint
anataliocs 83ddaac
Fix script perms
anataliocs 71ce798
Fix script perms
anataliocs 2e199ef
Use homebrew safely
anataliocs 4f8ef2f
Fix scripts
anataliocs 06a820b
improve caching
anataliocs 339e6ce
improve caching
anataliocs f1181ca
Update docs, cleanup and caching
anataliocs 9f037fe
code cleanup
anataliocs c540440
Clean up script to make sure stuff gets added to /Users/chris.anatali…
anataliocs 6bfd9e5
Clean up script to make sure stuff gets added to /Users/chris.anatali…
anataliocs 7445f71
Fix scripts
anataliocs bcd7007
Run checks and static analysis on bash scripts to fix
anataliocs bd50bfe
Run checks and static analysis on bash scripts to fix
anataliocs 903da9a
Create validate-devcontainer-json
anataliocs b0b0e6a
Add GH action to validate devcontainer json vs schema
anataliocs 2524666
Add GH action to validate scripts, test build and push prebuild cache
anataliocs 6eef356
Update validate-devcontainer-json.yml
anataliocs 42a606f
Fix GH action
anataliocs cb20752
Update tests.md
anataliocs abd0309
Update validate-devcontainer-json.yml
anataliocs 2f49dda
JSON Schema validation on GH Action
anataliocs 1d9cc22
JSON Schema validation on GH Action
anataliocs 0c52028
Getting JSON Schema validation and script validation and build cache …
anataliocs 8b1a4f0
Add devcontainer cli to GH Action
anataliocs 1e0da9b
Add devcontainer cli to GH Action
anataliocs 664156a
Add devcontainer cli to GH Action
anataliocs add9aca
Add devcontainer cli to GH Action
anataliocs 5429261
Add devcontainer cli to GH Action
anataliocs 1fbacb8
Add devcontainer cli to GH Action
anataliocs 4dc1b4e
Add devcontainer cli to GH Action
anataliocs 42ea804
Green GH Action JSON validation and build jobs
anataliocs a64bbca
Green GH Action JSON validation and build jobs
anataliocs 6bb7ab4
Code cleanup
anataliocs 51efba9
Update welcome message and VSCode extensions
anataliocs 120b448
Update badge to use vscode web by default
anataliocs e56a6f3
Build stellar cli and sccache from gh release binary
anataliocs 6f689ad
Build stellar cli and sccache from gh release binary
anataliocs 9bd1248
Code cleanup
anataliocs 418379b
Code cleanup
anataliocs 1b04e0c
Tune down rust analyzer, spiking CPU to 100%
anataliocs be4cdc5
Update .devcontainer/Dockerfile
anataliocs 550b12d
Update build-and-test-devcontainer.yml
anataliocs 7dd2e34
Pin bats to commit hash
anataliocs 244e772
Merge branch 'migrate-to-devcontainers-poc' of github.com:anataliocs/…
anataliocs e866798
Clean-up bash scripts
anataliocs 7479e22
Cross-platform gh cli install
anataliocs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Use the official Rust image as a base | ||
FROM mcr.microsoft.com/devcontainers/rust:1.0.9-bullseye | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive \ | ||
PKG_CONFIG_PATH='/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/share/pkgconfig' \ | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \ | ||
CARGO_INCREMENTAL=0 \ | ||
SCCACHE_DIR=/home/vscode/.cache/sccache \ | ||
SCCACHE_CONF=/home/vscode/.config/sccache/config \ | ||
SCCACHE_DIRECT=true \ | ||
RUSTC_WRAPPER=sccache \ | ||
SCCACHE_CACHE_SIZE=5G | ||
|
||
# Enable Rust Bindings for Linux D-Bus interprocess communication(Required for Stellar CLI dependencies) | ||
RUN apt-get update && apt-get install -y \ | ||
libdbus-1-dev \ | ||
libudev-dev \ | ||
pkg-config \ | ||
dbus \ | ||
binaryen && apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p /home/linuxbrew/ && \ | ||
chown -R vscode:vscode /home/linuxbrew/ | ||
|
||
USER vscode | ||
|
||
RUN HOMEBREW_BUNDLE_NO_UPGRADE=1 HOMEBREW_BUNDLE_INSTALL_CLEANUP=1 HOMEBREW_NO_INSTALL_UPGRADE=1 && \ | ||
HOMEBREW_NO_ANALYTICS=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_ENV_SYNC_STRICT=1 && \ | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && \ | ||
/home/linuxbrew/.linuxbrew/bin/brew install sccache cargo-watch stellar-cli && \ | ||
/home/linuxbrew/.linuxbrew/bin/brew cleanup --scrub | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"name": "Soroban Examples Dev Container(Debian Linux)", | ||
"dockerFile": "Dockerfile", | ||
"context": "..", | ||
"remoteUser": "vscode", | ||
"build": { | ||
"cacheFrom": [ | ||
"chrisstellar/vsc-soroban-examples-oci-prebuild", | ||
"chrisstellar/vsc-soroban-examples-95cce9-prebuild" | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
"options": [ | ||
"--platform=linux/amd64" | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
"args": { | ||
"DEBIAN_VERSION": "bullseye", | ||
"BUILDKIT_INLINE_CACHE": "1" | ||
} | ||
}, | ||
"hostRequirements": { | ||
"cpus": 4, | ||
"memory": "16", | ||
"storage": "32" | ||
}, | ||
"forwardPorts": [ | ||
2222, | ||
4226 | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
"portsAttributes": { | ||
"2222": { | ||
"onAutoForward": "notify", | ||
"label": "ssh", | ||
"requireLocalPort": true | ||
}, | ||
"4226": { | ||
"label": "sccache" | ||
} | ||
}, | ||
"remoteEnv": { | ||
"STELLAR_RPC_URL": "https://soroban-testnet.stellar.org", | ||
"STELLAR_NETWORK_PASSPHRASE": "Test SDF Network ; September 2015" | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2.5.3": {}, | ||
"ghcr.io/devcontainers/features/rust:1.3.1": { | ||
"targets": "wasm32-unknown-unknown", | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"profile": "default", | ||
"version": "1.81" | ||
} | ||
}, | ||
"customizations": { | ||
"codespaces": { | ||
"openFiles": [ | ||
"README.md", | ||
"FULL_HELP_DOCS.md", | ||
"increment/src/lib.rs", | ||
"increment/src/test.rs" | ||
] | ||
}, | ||
"vscode": { | ||
"extensions": [ | ||
"rust-lang.rust-analyzer", | ||
"vadimcn.vscode-lldb", | ||
"tamasfe.even-better-toml", | ||
"fill-labs.dependi", | ||
"ms-vscode.makefile-tools" | ||
], | ||
"settings": { | ||
"workbench.settings.editor": "json", | ||
"npm.autoDetect": false, | ||
"telemetry.enableTelemetry": false, | ||
"rust-analyzer.check.command": "clippy", | ||
"terminal.integrated.allowChords": true, | ||
"terminal.integrated.copyOnSelection": true, | ||
"terminal.integrated.commandsToSkipShell": [ | ||
"-workbench.action.terminal.copySelection", | ||
"-workbench.action.terminal.paste", | ||
"-workbench.action.terminal.pasteSelection" | ||
] | ||
} | ||
} | ||
}, | ||
"initializeCommand": "", | ||
"onCreateCommand": "", | ||
"updateContentCommand": "", | ||
"postCreateCommand": "", | ||
"postStartCommand": ".devcontainer/post_start_cli_autocomplete.sh", | ||
"postAttachCommand": ".devcontainer/post_attach_welcome_text.sh" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
clear | ||
|
||
echo "=========================================" | ||
echo " ✅ Getting Started with the Stellar CLI" | ||
echo "=========================================" | ||
echo "" | ||
echo " ⚙️ Setup testnet:" | ||
echo " stellar network use testnet" | ||
echo "" | ||
echo " 🆔 Configure an Identity:" | ||
echo " stellar keys generate --global alice --network testnet --fund" | ||
echo " stellar keys address alice" | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "" | ||
echo " 🛠️ Build a contract(For specific example. Replace 'alloc' with desired project):" | ||
echo " stellar contract build --manifest-path $CODESPACE_VSCODE_FOLDER/alloc/Cargo.toml" | ||
echo "" | ||
echo " 🧪 Run tests | 🔨Build Projects" | ||
echo " ⚠️ Running make all in the root directory will fill up a 32GB storage instance" | ||
echo " cd account" | ||
echo " cargo test ⭐️make all " | ||
echo "" | ||
echo " 📖 Stellar CLI Manual(cmd+click) 🔗 https://developers.stellar.org/docs/tools/cli/stellar-cli" | ||
echo " 👩🔬 Stellar Lab(cmd+click) 🔗 https://lab.stellar.org/" | ||
echo "=========================================" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Add Brew and Stellar CLI to $PATH and terminals | ||
chmod 644 ~/.bashrc && chmod 644 ~/.zshrc | ||
chmod 644 ~/.profile && chmod 644 ~/.zprofile | ||
test -d /home/linuxbrew/.linuxbrew && echo "/home/linuxbrew/.linuxbrew/bin/brew" >> ~/.zprofile | ||
test -d /home/linuxbrew/.linuxbrew && echo "/home/linuxbrew/.linuxbrew/bin/brew" >> ~/.zshrc | ||
|
||
test -d /home/linuxbrew/.linuxbrew && echo "/home/linuxbrew/.linuxbrew/bin/brew" >> ~/.profile | ||
test -d /home/linuxbrew/.linuxbrew && echo "/home/linuxbrew/.linuxbrew/bin/brew" >> ~/.bashrc | ||
|
||
export PATH="/home/linuxbrew/.linuxbrew/bin/brew":$PATH | ||
echo "export PATH='/home/linuxbrew/.linuxbrew/bin:$PATH'" >> ~/.zshrc | ||
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH" | ||
echo "export PATH='/home/linuxbrew/.linuxbrew/bin:$PATH'" >> ~/.bashrc | ||
# shellcheck source=/Users/chris.anatalio/.bashrc | ||
source ~/.bashrc | ||
# shellcheck source=/Users/chris.anatalio/.zshrc | ||
source ~/.zshrc | ||
|
||
# Stellar CLI Auto-Complete | ||
chmod 644 ~/.bashrc && \ | ||
echo "source <(stellar completion --shell bash)" >>~/.bashrc && \ | ||
chmod 644 ~/.zshrc && \ | ||
echo "source <(stellar completion --shell zsh)" >>~/.zshrc && \ | ||
echo "Enabled Stellar CLI auto-completion" | ||
|
||
# Store exit status of the previous command | ||
result=$? | ||
|
||
# Check the exit status and provide informative output | ||
if [ $result -eq 0 ]; then | ||
echo " ✅ postStartCliAutocomplete.sh executed successfully" | ||
else | ||
echo " ❌ Error executing postStartCliAutocomplete.sh" | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# Define devcontainer configuration directory | ||
devcontainer_dir=".devcontainer" | ||
|
||
# Define configuration file path | ||
config_file="devcontainer.json" | ||
|
||
# Use env vars or enter in your own values here. | ||
### | ||
|
||
# Example | ||
# - buildpack-deps:bookworm | ||
# - buildpack-deps:bookworm2 | ||
# - /User/cache | ||
|
||
pre_build_image=$1 | ||
oci_pre_build_image=$2 | ||
|
||
build_details_dir="z-dc-build-info/" | ||
build_details_file="build-details.json" | ||
|
||
if [ ! -e "${build_details_dir}" ]; then | ||
mkdir -p "${build_details_dir}" | ||
fi | ||
|
||
if [ ! -e "${build_details_dir}${build_details_file}" ]; then | ||
touch "${build_details_dir}${build_details_file}" | ||
fi | ||
|
||
# Build the devcontainer | ||
output=$(devcontainer build \ | ||
--workspace-folder . \ | ||
--config $devcontainer_dir/$config_file \ | ||
--output type=image,name="${pre_build_image}:later") | ||
|
||
#--dotfiles-repository | ||
|
||
# Check the exit status and push pre-build | ||
if [ "$output" ]; then | ||
echo " ✅ Devcontainer built successfully" | ||
|
||
# Extract imageName from JSON output using jq | ||
image_name=$(echo "$output" | jq -r '.imageName[0]') | ||
echo " 🔹 Image name: ${image_name}" | ||
docker inspect "${image_name}" >> "${build_details_dir}${build_details_file}" | ||
|
||
echo " ⚙️ Build info available at ${build_details_dir}${build_details_file}" | ||
|
||
else | ||
echo " ❌ Error building devcontainer. Please check logs above." | ||
exit 1 | ||
fi | ||
|
||
# Build the devcontainer again with OCI Output | ||
oci_output=$(devcontainer build \ | ||
--workspace-folder . \ | ||
--config $devcontainer_dir/$config_file \ | ||
--output type=image,name="${oci_pre_build_image}:latest",mode=max,oci-mediatypes=true,compression=zstd) | ||
|
||
# Extract ociImageName from JSON output using jq | ||
oci_image_name=$(echo "$oci_output" | jq -r '.imageName[0]') | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.