Skip to content
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

add preliminary support for code spaces #46

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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"
},
"customizations": {
"vscode": {
"extensions": [
"1YiB.rust-bundle"
]
}
}

// 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"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
80 changes: 80 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
84 changes: 84 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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="[email protected]/anagrambuild/bonsol.git" \
org.label-schema.vendor="anagram.xyz" \
org.label-schema.schema-version="1.0" \
org.opencontainers.image.description="Bonsol Development Container"