From 4605bf5e2b70afdc26cf5a90a9053599417df963 Mon Sep 17 00:00:00 2001 From: John Cairns Date: Tue, 15 Oct 2024 14:58:54 -0500 Subject: [PATCH 1/2] chore: github codespaces --- .devcontainer/devcontainer.json | 26 ++++++++++ .github/dependabot.yml | 12 +++++ Dockerfile | 84 +++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/dependabot.yml create mode 100644 Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..8d96444 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + "build": { + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerfile": "../Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f33a02c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6949866 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,84 @@ +# Development Container +# Stage 1: Build yamlfmt +FROM golang:1 AS go-builder +# defined from build kit +# DOCKER_BUILDKIT=1 docker build . -t ... +ARG TARGETARCH + +# Install yamlfmt +WORKDIR /yamlfmt +RUN go install github.com/google/yamlfmt/cmd/yamlfmt@latest && \ + strip $(which yamlfmt) && \ + yamlfmt --version + +# Stage 2: Rust Development Container +FROM rust:1-slim +ARG TARGETARCH + +# Install packages +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + binutils \ + ca-certificates \ + clang \ + cmake \ + curl \ + git \ + gnupg2 \ + libssl-dev \ + make \ + ninja-build \ + perl \ + pkg-config \ + protobuf-c-compiler \ + python3 \ + python3-pip \ + ripgrep \ + sudo \ + valgrind \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN echo "building platform $(uname -m)" + +# create dev user +RUN useradd --create-home --shell /bin/bash bonsol +RUN usermod -a -G sudo bonsol +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +## Rust +ENV USER=bonsol +COPY --chown=${USER}:${USER} --from=go-builder /go/bin/yamlfmt /go/bin/yamlfmt +USER bonsol +ENV PATH=${PATH}:/go/bin + +# Set user and working directory +ARG PACKAGE=bonsol +USER bonsol +WORKDIR /workspaces/${PACKAGE} + +# Install Rust components +RUN rustup component add \ + rustfmt \ + clippy \ + rust-analyzer + +RUN cargo install cargo-binstall +RUN yes | cargo binstall cargo-risczero +RUN cargo risczero build-toolchain + +# Clean up +RUN rm -rf /home/bonsol/.cargo/registry /home/bonsol/.cargo/git + +ENV PATH=${PATH}:/home/bonsol/.cargo/bin + +LABEL \ + org.label-schema.name="bonsol" \ + org.label-schema.description="Bonsol Development Container" \ + org.label-schema.url="https://github.com/anagrambuild/bonsol" \ + org.label-schema.vcs-url="git@github.com/anagrambuild/bonsol.git" \ + org.label-schema.vendor="anagram.xyz" \ + org.label-schema.schema-version="1.0" \ + org.opencontainers.image.description="Bonsol Development Container" From 9ae8dd5625f7fff6415d080c0910a9cbea2ff43c Mon Sep 17 00:00:00 2001 From: John Cairns Date: Tue, 15 Oct 2024 17:44:58 -0500 Subject: [PATCH 2/2] chore: add devcontainer extensions and vscode tasks --- .devcontainer/devcontainer.json | 7 +++ .vscode/tasks.json | 80 +++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8d96444..a93a058 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,6 +7,13 @@ "context": "..", // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. "dockerfile": "../Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": [ + "1YiB.rust-bundle" + ] + } } // Features to add to the dev container. More info: https://containers.dev/features. diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..7ce55a2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,80 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "fmt", + "type": "shell", + "command": "cargo fmt --check", + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "build", + "isDefault": "false" + } + }, + { + "label": "lint", + "type": "shell", + "command": "cargo clippy --all-features --no-deps", + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "build", + "isDefault": "false" + } + }, + { + "label": "build", + "type": "shell", + "command": "cargo build", + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "build", + "isDefault": "false" + } + }, + { + "label": "check", + "type": "shell", + "command": "cargo check", + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "build", + "isDefault": "true" + } + }, + { + "label": "test", + "type": "shell", + "command": "cargo test --workspace --all-features --no-fail-fast", + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "test", + "isDefault": "true" + } + }, + { + "label": "doc", + "type": "shell", + "command": "cargo doc --no-deps", + "options": { + "cwd": "${workspaceFolder}" + }, + "dependsOn": "check", + "group": { + "kind": "build", + "isDefault": "false" + } + } + ] +} \ No newline at end of file