Skip to content

Commit

Permalink
publishing devcontainers to ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
njelich committed Feb 3, 2024
1 parent 945da68 commit b80a6df
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 32 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
File renamed without changes.
File renamed without changes.
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"
}
}
}
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"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"]
},
"vscode": {
"extensions": ["rust-lang.rust-analyzer", "serayuzgur.crates", "njpwerner.autodocstring", "dustypomerleau.rust-syntax"]
}
}
}
5 changes: 5 additions & 0 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
@@ -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
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": ["ghcr.io/devcontainers/features/rust", "ghcr.io/lee-orr/rusty-dev-containers/cargo-binstall"]
}
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
21 changes: 21 additions & 0 deletions .github/publish-devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Publish Devcontainer Prebuild"
on:
workflow_dispatch:
release:
types: published

jobs:
permissions:
contents: read
packages: write
publish-features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/njelich/near-devcontainer
cacheFrom: ghcr.io/njelich/near-devcontainer
push: always
24 changes: 24 additions & 0 deletions .github/publish-features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Publish Devcontainer Features"
on:
workflow_dispatch:
release:
types: published

jobs:
permissions:
contents: read
packages: write
publish-features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: "Publish cargo-near"
uses: devcontainers-community/publish-feature@v1
with:
path: ".devcontainer/cargo-near"

- name: "Publish near-cli"
uses: devcontainers-community/publish-feature@v1
with:
path: ".devcontainer/near-cli"
16 changes: 0 additions & 16 deletions .github/validate.yml

This file was deleted.

17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
# NEAR Dev Containers

A collection of dev containers and features designed for working with NEAR in various contexts.

## Usage

To use a feature from this repository, add it to a devcontainer.json. You can read more about devcontainer features here: https://containers.dev/features

## Compatibility

Note that all these images depend on having the rust feature set up (`ghcr.io/devcontainers/features/rust:1`), as well as using either `debian:latest` or `ubuntu:latest` as the base image since the default devcontainer image causes issues with permissions.

## Features

| Feature | OCI Image | Description |
| Cargo Near | TODO | Installs [Cargo Near](https://github.com/near/cargo-near) - Cargo extension for building near-sdk-rs smart contracts and ABI schemas on NEAR |
# TODO

0 comments on commit b80a6df

Please sign in to comment.