Skip to content
Open
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
48 changes: 48 additions & 0 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -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}
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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