diff --git a/.devcontainer/Dockerfile.dev b/.devcontainer/Dockerfile.dev new file mode 100644 index 00000000..34413b04 --- /dev/null +++ b/.devcontainer/Dockerfile.dev @@ -0,0 +1,48 @@ +# syntax=docker/dockerfile:1.7 +FROM rust:1.95-bookworm AS dev + +USER root + +# Development dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + bash-completion \ + ca-certificates \ + curl \ + fuse3 \ + git \ + libfuse3-3 \ + libfuse3-dev \ + make \ + nfs-common \ + perl \ + pkg-config \ + sudo \ + xfslibs-dev \ + && rm -rf /tmp/* /var/lib/apt/lists/* + +# Rust dev tooling required by the lint/format gate. +RUN rustup component add rustfmt clippy + +# Allow non-root FUSE mounts (needed for `cargo test --features fuse` dev runs). +RUN echo 'user_allow_other' >> /etc/fuse.conf + +# Developer user, in a separate layer from apt for cache isolation. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=1000 +RUN groupadd --gid "${USER_GID}" "${USERNAME}" \ + && useradd --uid "${USER_UID}" --gid "${USER_GID}" --create-home --shell /bin/bash "${USERNAME}" \ + && usermod -aG sudo "${USERNAME}" \ + && echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/${USERNAME}" \ + && chmod 0440 "/etc/sudoers.d/${USERNAME}" + +# Ensure the non-root user can write to the cargo cache so `cargo` works without root inside the container. +ENV CARGO_HOME=/usr/local/cargo +ENV PATH=${CARGO_HOME}/bin:${PATH} +RUN mkdir -p "${CARGO_HOME}" && chown -R "${USERNAME}:${USERNAME}" "${CARGO_HOME}" +# Use the system git client for the git-based crates (xet-core, fuser fork). +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true +ENV RUST_BACKTRACE=full + +USER ${USERNAME} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..5b6e3f26 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "build": { + "context": ".", + "dockerfile": "Dockerfile.dev" + }, + "runArgs": [ + "--cap-add=sys_admin", + "--device=/dev/fuse:/dev/fuse" + ], + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer" + ], + "settings": { + "editor.formatOnSave": true, + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" + }, + "rust-analyzer.cargo.features": "all", + "rust-analyzer.cargo-watch.enable": true + } + } + } +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f19c108d --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +# Targets +.PHONY: all build check clean doc fmt release test + +BUILD_TOOL := cargo + +all: clean fmt build + +build: + @$(BUILD_TOOL) build + +check: + @$(BUILD_TOOL) check + +clean: + @$(BUILD_TOOL) clean + +doc: + @$(BUILD_TOOL) doc --no-deps + +fmt: + @$(BUILD_TOOL) fmt + +release: clean + @$(BUILD_TOOL) build --release + +test: + @$(BUILD_TOOL) test