Skip to content

Commit 98ba428

Browse files
committed
fix(devcontainer): add configuration to limit rust-analyzer extension memory usage
1 parent 82c72f9 commit 98ba428

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,30 @@ ARG RUST_VERSION=1.96
2121
FROM rust:${RUST_VERSION}-slim-trixie
2222

2323
# Build + runtime dependencies mirror the production Dockerfile builder
24-
# stage (native TLS, hwloc topology, udev) plus the Node.js toolchain the
25-
# web UI build requires. git/curl/sudo/pkg-config round out the dev shell.
24+
# stage (native TLS, hwloc topology, udev). git/curl/gnupg/sudo/pkg-config
25+
# round out the dev shell.
2626
RUN apt-get update && apt-get install -y --no-install-recommends \
2727
build-essential \
2828
ca-certificates \
2929
curl \
3030
git \
31+
gnupg \
3132
pkg-config \
3233
libssl-dev \
3334
libhwloc-dev \
3435
libudev-dev \
3536
liblzma5 \
36-
nodejs \
37-
npm \
3837
sudo \
3938
&& rm -rf /var/lib/apt/lists/*
4039

40+
# Pin Node.js to the major version CI uses to build the web UI
41+
# (.github/workflows/_build_rust_artifacts.yml). NodeSource ships nodejs
42+
# with a bundled npm, so Debian's unversioned packages are not used.
43+
ARG NODE_VERSION=22
44+
RUN curl -fsSL "https://deb.nodesource.com/setup_${NODE_VERSION}.x" | bash - \
45+
&& apt-get install -y --no-install-recommends nodejs \
46+
&& rm -rf /var/lib/apt/lists/*
47+
4148
# Pre-fetch the pinned toolchain components (rustfmt, clippy) so the first
4249
# in-container build does not stall resolving them. rust-src is added for
4350
# rust-analyzer sysroot / standard-library resolution.

.devcontainer/devcontainer.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"name": "Apache Iggy",
3+
"hostRequirements": {
4+
"cpus": 4,
5+
"memory": "16gb",
6+
"storage": "32gb"
7+
},
38
"build": {
49
"dockerfile": "Dockerfile",
510
"context": "..",
@@ -11,12 +16,18 @@
1116
"remoteUser": "vscode",
1217
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/iggy,type=bind,consistency=cached",
1318
"workspaceFolder": "/workspaces/iggy",
14-
"runArgs": ["--init"],
19+
"runArgs": [
20+
"--init",
21+
"--security-opt", "seccomp=unconfined",
22+
"--ulimit", "memlock=-1:-1",
23+
"--cap-add=SYS_NICE"
24+
],
1525
"mounts": [
1626
"type=volume,source=iggy-cargo-registry,target=/usr/local/cargo/registry",
1727
"type=volume,source=iggy-target,target=/workspaces/iggy/target"
1828
],
1929
"containerEnv": {
30+
"CARGO_BUILD_JOBS": "4",
2031
"IGGY_HTTP_ADDRESS": "0.0.0.0:3000",
2132
"IGGY_QUIC_ADDRESS": "0.0.0.0:8080",
2233
"IGGY_TCP_ADDRESS": "0.0.0.0:8090",
@@ -41,8 +52,10 @@
4152
"ms-azuretools.vscode-docker"
4253
],
4354
"settings": {
44-
"rust-analyzer.check.command": "clippy",
45-
"rust-analyzer.cargo.features": "all",
55+
"rust-analyzer.cargo.buildScripts.enable": true,
56+
"rust-analyzer.procMacro.enable": true,
57+
"rust-analyzer.numThreads": 4,
58+
"rust-analyzer.cargo.extraEnv": { "CARGO_BUILD_JOBS": "4" },
4659
"editor.formatOnSave": true,
4760
"[rust]": {
4861
"editor.defaultFormatter": "rust-lang.rust-analyzer"

0 commit comments

Comments
 (0)