diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1927343 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +# [Choice] Debian OS version (use bookworm, or bullseye on local arm64/Apple Silicon): bookworm, buster, bullseye +ARG VARIANT="bookworm" +FROM rust:1-${VARIANT} + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131 + && apt-get purge -y imagemagick imagemagick-6-common + +# Additional packages: +# - libudev-dev: required for the hidapi crate (cargo-near dependency) +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends libudev-dev \ No newline at end of file diff --git a/.devcontainer/cargo-near/README.md b/.devcontainer/cargo-near/README.md new file mode 100644 index 0000000..978a5d7 --- /dev/null +++ b/.devcontainer/cargo-near/README.md @@ -0,0 +1,18 @@ +# Cargo Near (cargo-near) + +A feature to install cargo-near + +## Example Usage + +```json +"features": { + "": {} // TODO +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +| ---------- | ----------- | ---- | ------------- | + +--- diff --git a/.devcontainer/cargo-near/devcontainer-feature.json b/.devcontainer/cargo-near/devcontainer-feature.json new file mode 100644 index 0000000..4939c1f --- /dev/null +++ b/.devcontainer/cargo-near/devcontainer-feature.json @@ -0,0 +1,8 @@ +{ + "name": "Cargo Near", + "id": "cargo-near", + "version": "0.1.0", + "description": "A feature to install cargo-near", + "options": {}, + "installsAfter": ["ghcr.io/devcontainers/features/rust", "ghcr.io/lee-orr/rusty-dev-containers/cargo-binstall"] +} diff --git a/.devcontainer/cargo-near/install.sh b/.devcontainer/cargo-near/install.sh new file mode 100644 index 0000000..12826ec --- /dev/null +++ b/.devcontainer/cargo-near/install.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +if ! (which rustup > /dev/null && which cargo > /dev/null); then + which curl > /dev/null || (apt update && apt install curl -y -qq) + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env +fi + +dpkg -l | grep build-essential || (apt update && apt install build-essential -y -qq) + +if ! cargo install --list | grep "cargo-binstall" > /dev/null; then + curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +fi + +cargo binstall cargo-near --locked -y \ No newline at end of file diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000..bbbace7 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,34 @@ +{ + "features": { + "ghcr.io/devcontainers-community/features/llvm": { + "version": "3.1.0", + "resolved": "ghcr.io/devcontainers-community/features/llvm@sha256:0b1cb680de18860c92d70d8b921b50f166ab875936a047b4cbf2068b69ef7bdf", + "integrity": "sha256:0b1cb680de18860c92d70d8b921b50f166ab875936a047b4cbf2068b69ef7bdf" + }, + "ghcr.io/devcontainers/features/common-utils:2": { + "version": "2.4.0", + "resolved": "ghcr.io/devcontainers/features/common-utils@sha256:cd9c4413255c3b71fb716e63ee2df245c81c7262b858cf77406a68c80d09f12e", + "integrity": "sha256:cd9c4413255c3b71fb716e63ee2df245c81c7262b858cf77406a68c80d09f12e" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "version": "2.7.1", + "resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:f6a73ee06601d703db7d95d03e415cab229e78df92bb5002e8559bcfc047fec6", + "integrity": "sha256:f6a73ee06601d703db7d95d03e415cab229e78df92bb5002e8559bcfc047fec6" + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "1.1.6", + "resolved": "ghcr.io/devcontainers/features/git@sha256:f839be8a0203abe12c917b262b1a1330b8286f9576ef21ea4a26ed60c5bc9947", + "integrity": "sha256:f839be8a0203abe12c917b262b1a1330b8286f9576ef21ea4a26ed60c5bc9947" + }, + "ghcr.io/devcontainers/features/rust:1": { + "version": "1.1.1", + "resolved": "ghcr.io/devcontainers/features/rust@sha256:e81d6a952842a4e10d1e4dbb9cb295a1ead44befd8212522a67b8867427b929d", + "integrity": "sha256:e81d6a952842a4e10d1e4dbb9cb295a1ead44befd8212522a67b8867427b929d" + }, + "ghcr.io/lee-orr/rusty-dev-containers/cargo-binstall:0": { + "version": "0.1.0", + "resolved": "ghcr.io/lee-orr/rusty-dev-containers/cargo-binstall@sha256:08f406c6101dccc5a872cff117f8731b4f8b08a1d8e58eac0fdd0422e84417a0", + "integrity": "sha256:08f406c6101dccc5a872cff117f8731b4f8b08a1d8e58eac0fdd0422e84417a0" + } + } +} \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..124af71 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +{ + "name": "NEAR Devcontainer Rust", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, + + "features": { + "./cargo-near": {}, + "./near-cli": {}, + "ghcr.io/devcontainers-community/features/llvm": {}, + "ghcr.io/devcontainers/features/rust:1": "latest", + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/git:1": { + "version": "latest", + "ppa": "false" + }, + "ghcr.io/lee-orr/rusty-dev-containers/cargo-binstall:0": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "username": "vscode", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "true" + } + }, + + // 👇 Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + "postCreateCommand": "bash .devcontainer/init.sh", + + "remoteUser": "vscode", + + "customizations": { + "codespaces": { + "openFiles": ["README.md", "src/lib.rs", "tests/test_basics.rs"] + } + } +} diff --git a/.devcontainer/init.sh b/.devcontainer/init.sh new file mode 100644 index 0000000..7fe7f00 --- /dev/null +++ b/.devcontainer/init.sh @@ -0,0 +1,5 @@ +# Get correct rust for repo (will be redundant once repo changes to stable) +cargo + +# Cache images that will be used on source verification +docker image pull nearprotocol/contract-builder:latest-amd64 \ No newline at end of file diff --git a/.devcontainer/near-cli/README.md b/.devcontainer/near-cli/README.md new file mode 100644 index 0000000..9f2cae2 --- /dev/null +++ b/.devcontainer/near-cli/README.md @@ -0,0 +1,18 @@ +# Near CLII (near-cli-rs) + +A feature to install near-cli-rs + +## Example Usage + +```json +"features": { + "": {} // TODO +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +| ---------- | ----------- | ---- | ------------- | + +--- diff --git a/.devcontainer/near-cli/devcontainer-feature.json b/.devcontainer/near-cli/devcontainer-feature.json new file mode 100644 index 0000000..1736330 --- /dev/null +++ b/.devcontainer/near-cli/devcontainer-feature.json @@ -0,0 +1,8 @@ +{ + "name": "Near CLI", + "id": "near-cli", + "version": "0.1.0", + "description": "A feature to install the near-cli", + "options": {}, + "installsAfter": ["ghcr.io/devcontainers/features/rust", "ghcr.io/lee-orr/rusty-dev-containers/cargo-binstall"] +} diff --git a/.devcontainer/near-cli/install.sh b/.devcontainer/near-cli/install.sh new file mode 100644 index 0000000..b7a73eb --- /dev/null +++ b/.devcontainer/near-cli/install.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +if ! (which rustup > /dev/null && which cargo > /dev/null); then + which curl > /dev/null || (apt update && apt install curl -y -qq) + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env +fi + +dpkg -l | grep build-essential || (apt update && apt install build-essential -y -qq) + +if ! cargo install --list | grep "cargo-binstall" > /dev/null; then + curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash +fi + +cargo binstall near-cli-rs --locked -y \ No newline at end of file