Skip to content

Commit

Permalink
devcontainer config
Browse files Browse the repository at this point in the history
  • Loading branch information
njelich committed Jan 30, 2024
1 parent 9d53496 commit c7284db
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .devcontainer/cargo-near/README.md
Original file line number Diff line number Diff line change
@@ -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 |
| ---------- | ----------- | ---- | ------------- |

---
8 changes: 8 additions & 0 deletions .devcontainer/cargo-near/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"]
}
16 changes: 16 additions & 0 deletions .devcontainer/cargo-near/install.sh
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "NEAR Devcontainer Rust",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},

// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
"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",

// 👇 Configure tool-specific properties.
// "customizations": {},

// "remoteUser": "vscode",

"customizations": {
"codespaces": {
"openFiles": ["README.md", "src/lib.rs", "tests/test_basics.rs"]
}
}
}
3 changes: 3 additions & 0 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cargo

docker image pull nearprotocol/contract-builder:latest-amd64
18 changes: 18 additions & 0 deletions .devcontainer/near-cli/README.md
Original file line number Diff line number Diff line change
@@ -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 |
| ---------- | ----------- | ---- | ------------- |

---
8 changes: 8 additions & 0 deletions .devcontainer/near-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Near CLI",
"id": "near-cli",
"version": "0.1.0",
"description": "A feature to install the near-cli",
"options": {},
"installsAfter": []
}
16 changes: 16 additions & 0 deletions .devcontainer/near-cli/install.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c7284db

Please sign in to comment.