diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3c0db6643ee3c..3bd6887c82805 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,33 +1,72 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/go/.devcontainer/base.Dockerfile - -# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster -ARG VARIANT="1.18-bullseye" -FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} - -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends \ - # Chromium for running Turbopack benchmarks - chromium \ - # Used for plotters graph visualizations in turbopack benchmarks - libfontconfig1-dev - -# Add hyperfine, a useful benchmarking tool -RUN dpkgArch="$(dpkg --print-architecture)"; \ - wget "https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine_1.12.0_${dpkgArch}.deb" && dpkg -i "hyperfine_1.12.0_${dpkgArch}.deb" - -# -# Everything below is run as the vscode user. If superuser permissions are necessary, -# run it before this. Otherwise, prefer running as the vscode user. -# -USER vscode +# Use Ubuntu 22.04 LTS as base image +FROM mcr.microsoft.com/vscode/devcontainers/base:ubuntu-22.04 + +# Set environment variables +ENV DEBIAN_FRONTEND=noninteractive +ENV RUSTUP_HOME=/usr/local/rustup +ENV CARGO_HOME=/usr/local/cargo +ENV PATH=/usr/local/cargo/bin:$PATH +ENV RUST_VERSION=nightly-2025-06-20 + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + # Build essentials + build-essential \ + pkg-config \ + # LLD linker (required on Linux per CONTRIBUTING.md) + lld \ + # Protocol Buffers compiler + protobuf-compiler \ + # Cap'n Proto + capnproto \ + libcapnp-dev \ + # Testing utilities (optional but useful) + jq \ + zstd \ + # SSL development libraries + libssl-dev \ + # Additional utilities + curl \ + wget \ + git \ + ca-certificates \ + gnupg \ + lsb-release \ + && rm -rf /var/lib/apt/lists/* + +# Install Node.js v22 (using NodeSource repository for exact version control) +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ + && apt-get install -y nodejs \ + && rm -rf /var/lib/apt/lists/* -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -ARG NODE_VERSION="none" -RUN if [ "${NODE_VERSION}" != "none" ]; then umask 0002 && sh -c ". /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION}" 2>&1; fi +# Install pnpm globally (specific version as per package.json) +RUN npm install -g pnpm@8.14.0 + +# Install Rust with the specific nightly version and components +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + --default-toolchain ${RUST_VERSION} \ + --profile minimal \ + --component rustfmt,clippy \ + -y \ + && chmod -R a+w $RUSTUP_HOME $CARGO_HOME + +# Create cache directories for better performance +RUN mkdir -p /home/vscode/.cache /usr/local/cargo \ + && chown -R vscode:vscode /home/vscode/.cache /usr/local/cargo + +# Set the default user to vscode +USER vscode -RUN sh -c ". /usr/local/share/nvm/nvm.sh && npm install -g vercel yarn yalc pnpm nodemon" 2>&1 +# Verify installations +RUN node --version \ + && npm --version \ + && pnpm --version \ + && rustc --version \ + && cargo --version \ + && protoc --version \ + && capnp --version \ + && jq --version \ + && zstd --version \ + && which lld -# The installer from https://rustup.rs/ homepage, with the following changes: -# * `-y` to accept without interactivity -# * `--default-toolchain none` to avoid installing stable rust. Our specific toolchain is installed post-create. -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none +WORKDIR /workspace \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b829f934fbb3c..ba7d10135d950 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,52 +1,51 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/go { - "name": "turbo (go, node, rust)", + "name": "Turborepo Development Environment", "build": { "dockerfile": "Dockerfile", - "args": { - // Update the VARIANT arg to pick a version of Go: 1, 1.18, 1.17 - // Append -bullseye or -buster to pin to an OS version. - // Use -bullseye variants on local arm64/Apple Silicon. - "VARIANT": "1.18-bullseye", - // Options - "NODE_VERSION": "lts/*" - } + "context": "." }, "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "bradlc.vscode-tailwindcss", - "christian-kohler.npm-intellisense", - "dbaeumer.vscode-eslint", - "eamodio.gitlens", - "EditorConfig.EditorConfig", - "esbenp.prettier-vscode", - "github.copilot", - "github.vscode-pull-request-github", - "golang.go", - "heybourn.headwind", - "rust-lang.rust-analyzer", - "silvenon.mdx", - "windmilleng.vscode-go-autotest", - "yzhang.markdown-all-in-one" - ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "cargo --version", - // Invoking `cargo` will eagerly install the toolchain specified in rust-toolchain file - - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode", "features": { - "docker-in-docker": "latest", - "git": "latest", - "github-cli": "latest" - } -} + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/git:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "bradlc.vscode-tailwindcss", + "esbenp.prettier-vscode", + "ms-vscode.vscode-json", + "ms-vscode.vscode-typescript-next", + "tamasfe.even-better-toml", + "vadimcn.vscode-lldb" + ], + "settings": { + "rust-analyzer.cargo.buildScripts.enable": true, + "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.rustfmt.rangeFormatting.enable": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" + }, + "[toml]": { + "editor.defaultFormatter": "tamasfe.even-better-toml" + }, + "typescript.preferences.importModuleSpecifier": "relative", + "javascript.preferences.importModuleSpecifier": "relative" + } + } + }, + "forwardPorts": [3000, 3001, 9000, 9001], + "postCreateCommand": "pnpm install && rustup component add llvm-tools-preview", + "remoteUser": "vscode", + "mounts": [ + "source=${localWorkspaceFolder}/.devcontainer/cache,target=/home/vscode/.cache,type=bind,consistency=cached", + "source=${localWorkspaceFolder}/.devcontainer/cargo,target=/usr/local/cargo,type=bind,consistency=cached" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 514d5d6ee3943..d4a35c430b147 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,7 @@ file_descriptor_set.bin # include test fixtures for vt100 !crates/turborepo-vt100/tests/data + +# DevContainer cache directories +.devcontainer/cache/ +.devcontainer/cargo/