Skip to content

Commit 82c72f9

Browse files
committed
feat(devcontainer): add devcontainer config for reproducible dev and
cross-platform code track. Provide a consistent development environment with the pinned Rust toolchain, build dependencies, and VS Code extensions to reduce contributor setup overhead and ensure reproducibility.
1 parent 45fac44 commit 82c72f9

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# Toolchain is pinned by rust-toolchain.toml (channel 1.96.0). The base
19+
# image ships rustup, so the pin auto-resolves on first cargo invocation.
20+
ARG RUST_VERSION=1.96
21+
FROM rust:${RUST_VERSION}-slim-trixie
22+
23+
# 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.
26+
RUN apt-get update && apt-get install -y --no-install-recommends \
27+
build-essential \
28+
ca-certificates \
29+
curl \
30+
git \
31+
pkg-config \
32+
libssl-dev \
33+
libhwloc-dev \
34+
libudev-dev \
35+
liblzma5 \
36+
nodejs \
37+
npm \
38+
sudo \
39+
&& rm -rf /var/lib/apt/lists/*
40+
41+
# Pre-fetch the pinned toolchain components (rustfmt, clippy) so the first
42+
# in-container build does not stall resolving them. rust-src is added for
43+
# rust-analyzer sysroot / standard-library resolution.
44+
COPY rust-toolchain.toml /tmp/rust-toolchain.toml
45+
RUN cd /tmp && rustup show && rustup component add rust-src && rm rust-toolchain.toml
46+
47+
# Create a non-root user matching the default VS Code devcontainer UID/GID
48+
# so bind-mounted workspace files keep sane ownership.
49+
ARG USERNAME=vscode
50+
ARG USER_UID=1000
51+
ARG USER_GID=${USER_UID}
52+
RUN groupadd --gid ${USER_GID} ${USERNAME} \
53+
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \
54+
&& echo "${USERNAME} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} \
55+
&& chmod 0440 /etc/sudoers.d/${USERNAME}
56+
57+
USER ${USERNAME}

.devcontainer/devcontainer.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "Apache Iggy",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"RUST_VERSION": "1.96"
8+
}
9+
},
10+
"features": {},
11+
"remoteUser": "vscode",
12+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/iggy,type=bind,consistency=cached",
13+
"workspaceFolder": "/workspaces/iggy",
14+
"runArgs": ["--init"],
15+
"mounts": [
16+
"type=volume,source=iggy-cargo-registry,target=/usr/local/cargo/registry",
17+
"type=volume,source=iggy-target,target=/workspaces/iggy/target"
18+
],
19+
"containerEnv": {
20+
"IGGY_HTTP_ADDRESS": "0.0.0.0:3000",
21+
"IGGY_QUIC_ADDRESS": "0.0.0.0:8080",
22+
"IGGY_TCP_ADDRESS": "0.0.0.0:8090",
23+
"IGGY_WEBSOCKET_ADDRESS": "0.0.0.0:8092"
24+
},
25+
"forwardPorts": [3000, 3050, 8080, 8090, 8092],
26+
"portsAttributes": {
27+
"3000": { "label": "HTTP (REST)" },
28+
"3050": { "label": "Web UI (vite dev)" },
29+
"8080": { "label": "QUIC" },
30+
"8090": { "label": "TCP (binary)" },
31+
"8092": { "label": "WebSocket" }
32+
},
33+
"postCreateCommand": "sudo chown -R vscode:vscode target /usr/local/cargo/registry 2>/dev/null; rustup show && npm --prefix web ci",
34+
"customizations": {
35+
"vscode": {
36+
"extensions": [
37+
"rust-lang.rust-analyzer",
38+
"tamasfe.even-better-toml",
39+
"vadimcn.vscode-lldb",
40+
"svelte.svelte-vscode",
41+
"ms-azuretools.vscode-docker"
42+
],
43+
"settings": {
44+
"rust-analyzer.check.command": "clippy",
45+
"rust-analyzer.cargo.features": "all",
46+
"editor.formatOnSave": true,
47+
"[rust]": {
48+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
49+
}
50+
}
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)