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
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8d1319f
Initial Devcontainers config
anataliocs Mar 31, 2025
fb4c43f
Update config
anataliocs Apr 1, 2025
e68310c
Update startup scripts
anataliocs Apr 1, 2025
c021c4f
Update devcontainer for stellar cli
anataliocs Apr 1, 2025
f0ace8e
Add cargo watch binaryen and make all entrypoint
anataliocs Apr 1, 2025
83ddaac
Fix script perms
anataliocs Apr 1, 2025
71ce798
Fix script perms
anataliocs Apr 1, 2025
2e199ef
Use homebrew safely
anataliocs Apr 1, 2025
4f8ef2f
Fix scripts
anataliocs Apr 1, 2025
06a820b
improve caching
anataliocs Apr 1, 2025
339e6ce
improve caching
anataliocs Apr 1, 2025
f1181ca
Update docs, cleanup and caching
anataliocs Apr 2, 2025
9f037fe
code cleanup
anataliocs Apr 2, 2025
c540440
Clean up script to make sure stuff gets added to /Users/chris.anatali…
anataliocs Apr 2, 2025
6bfd9e5
Clean up script to make sure stuff gets added to /Users/chris.anatali…
anataliocs Apr 2, 2025
7445f71
Fix scripts
anataliocs Apr 2, 2025
bcd7007
Run checks and static analysis on bash scripts to fix
anataliocs Apr 2, 2025
bd50bfe
Run checks and static analysis on bash scripts to fix
anataliocs Apr 2, 2025
903da9a
Create validate-devcontainer-json
anataliocs Apr 2, 2025
b0b0e6a
Add GH action to validate devcontainer json vs schema
anataliocs Apr 2, 2025
2524666
Add GH action to validate scripts, test build and push prebuild cache
anataliocs Apr 2, 2025
6eef356
Update validate-devcontainer-json.yml
anataliocs Apr 2, 2025
42a606f
Fix GH action
anataliocs Apr 2, 2025
cb20752
Update tests.md
anataliocs Apr 2, 2025
abd0309
Update validate-devcontainer-json.yml
anataliocs Apr 2, 2025
2f49dda
JSON Schema validation on GH Action
anataliocs Apr 3, 2025
1d9cc22
JSON Schema validation on GH Action
anataliocs Apr 3, 2025
0c52028
Getting JSON Schema validation and script validation and build cache …
anataliocs Apr 4, 2025
8b1a4f0
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
1e0da9b
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
664156a
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
add9aca
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
5429261
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
1fbacb8
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
4dc1b4e
Add devcontainer cli to GH Action
anataliocs Apr 4, 2025
42ea804
Green GH Action JSON validation and build jobs
anataliocs Apr 4, 2025
a64bbca
Green GH Action JSON validation and build jobs
anataliocs Apr 7, 2025
6bb7ab4
Code cleanup
anataliocs Apr 7, 2025
51efba9
Update welcome message and VSCode extensions
anataliocs Apr 7, 2025
120b448
Update badge to use vscode web by default
anataliocs Apr 7, 2025
e56a6f3
Build stellar cli and sccache from gh release binary
anataliocs Apr 7, 2025
6f689ad
Build stellar cli and sccache from gh release binary
anataliocs Apr 7, 2025
9bd1248
Code cleanup
anataliocs Apr 8, 2025
418379b
Code cleanup
anataliocs Apr 8, 2025
1b04e0c
Tune down rust analyzer, spiking CPU to 100%
anataliocs Apr 8, 2025
be4cdc5
Update .devcontainer/Dockerfile
anataliocs Apr 15, 2025
550b12d
Update build-and-test-devcontainer.yml
anataliocs Apr 15, 2025
7dd2e34
Pin bats to commit hash
anataliocs Apr 15, 2025
244e772
Merge branch 'migrate-to-devcontainers-poc' of github.com:anataliocs/…
anataliocs Apr 15, 2025
e866798
Clean-up bash scripts
anataliocs Apr 15, 2025
7479e22
Cross-platform gh cli install
anataliocs Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .devcontainer/Dockerfile
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







88 changes: 88 additions & 0 deletions .devcontainer/devcontainer.json
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"
],
"options": [
"--platform=linux/amd64"
],
"args": {
"DEBIAN_VERSION": "bullseye",
"BUILDKIT_INLINE_CACHE": "1"
}
},
"hostRequirements": {
"cpus": 4,
"memory": "16",
"storage": "32"
},
"forwardPorts": [
2222,
4226
],
"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",
"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"
}
28 changes: 28 additions & 0 deletions .devcontainer/post_attach_welcome_text.sh
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"
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 "========================================="

37 changes: 37 additions & 0 deletions .devcontainer/post_start_cli_autocomplete.sh
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
63 changes: 63 additions & 0 deletions .devcontainer/tests/build_devcontainer_ci.sh
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]')

Loading