You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by hg...@apache.org on 2026/07/21 11:12:34 UTC

(iggy) branch master updated: feat(configs): add devcontainer config for reproducible dev and cross-platform code track (#3656)

This is an automated email from the ASF dual-hosted git repository.

hubcio pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/master by this push:
     new be8c9c63b feat(configs): add devcontainer config for reproducible dev and cross-platform code track (#3656)
be8c9c63b is described below

commit be8c9c63b937dab17a98b231362f5c952b9f82bf
Author: Gunther Xing <ji...@gmail.com>
AuthorDate: Tue Jul 21 19:12:29 2026 +0800

    feat(configs): add devcontainer config for reproducible dev and cross-platform code track (#3656)
---
 .devcontainer/Dockerfile             | 64 +++++++++++++++++++++++++++++++++
 .devcontainer/devcontainer-lock.json |  9 +++++
 .devcontainer/devcontainer.json      | 68 ++++++++++++++++++++++++++++++++++++
 .devcontainer/notice.sh              | 51 +++++++++++++++++++++++++++
 scripts/ci/sync-rustc-version.sh     | 54 +++++++++++++++++++++++++---
 5 files changed, 242 insertions(+), 4 deletions(-)

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 000000000..8f1454542
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Toolchain is pinned by rust-toolchain.toml (channel 1.96.0). The base
+# image ships rustup, so the pin auto-resolves on first cargo invocation.
+ARG RUST_VERSION=1.96
+FROM rust:${RUST_VERSION}-slim-trixie
+
+# Build + runtime dependencies mirror the production Dockerfile builder
+# stage (native TLS, hwloc topology, udev). git/curl/gnupg/sudo/pkg-config
+# round out the dev shell.
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    build-essential \
+    ca-certificates \
+    curl \
+    git \
+    gnupg \
+    pkg-config \
+    libssl-dev \
+    libhwloc-dev \
+    libudev-dev \
+    liblzma5 \
+    sudo \
+    && rm -rf /var/lib/apt/lists/*
+
+# Pin Node.js to the major version CI uses to build the web UI
+# (.github/workflows/_build_rust_artifacts.yml). NodeSource ships nodejs
+# with a bundled npm, so Debian's unversioned packages are not used.
+ARG NODE_VERSION=22
+RUN curl -fsSL "https://deb.nodesource.com/setup_${NODE_VERSION}.x" | bash - \
+    && apt-get install -y --no-install-recommends nodejs \
+    && rm -rf /var/lib/apt/lists/*
+
+# Pre-fetch the pinned toolchain components (rustfmt, clippy) so the first
+# in-container build does not stall resolving them. rust-src is added for
+# rust-analyzer sysroot / standard-library resolution.
+COPY rust-toolchain.toml /tmp/rust-toolchain.toml
+RUN cd /tmp && rustup show && rustup component add rust-src && rm rust-toolchain.toml
+
+# Create a non-root user matching the default VS Code devcontainer UID/GID
+# so bind-mounted workspace files keep sane ownership.
+ARG USERNAME=vscode
+ARG USER_UID=1000
+ARG USER_GID=${USER_UID}
+RUN groupadd --gid ${USER_GID} ${USERNAME} \
+    && useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} \
+    && echo "${USERNAME} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} \
+    && chmod 0440 /etc/sudoers.d/${USERNAME}
+
+USER ${USERNAME}
diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json
new file mode 100644
index 000000000..e1fdaed91
--- /dev/null
+++ b/.devcontainer/devcontainer-lock.json
@@ -0,0 +1,9 @@
+{
+  "features": {
+    "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
+      "version": "1.10.0",
+      "resolved": "ghcr.io/devcontainers/features/docker-outside-of-docker@sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e",
+      "integrity": "sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e"
+    }
+  }
+}
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 000000000..450aad797
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,68 @@
+{
+  "name": "Apache Iggy",
+  "hostRequirements": {
+    "cpus": 4,
+    "memory": "16gb",
+    "storage": "32gb"
+  },
+  "build": {
+    "dockerfile": "Dockerfile",
+    "context": ".."
+  },
+  "features": {
+    "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
+      "moby": false
+    }
+  },
+  "remoteUser": "vscode",
+  "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/iggy,type=bind,consistency=cached",
+  "workspaceFolder": "/workspaces/iggy",
+  "runArgs": [
+    "--init",
+    "--security-opt", "seccomp=unconfined",
+    "--ulimit", "memlock=-1:-1",
+    "--cap-add=SYS_NICE",
+    "--publish", "8080:8080/udp"
+  ],
+  "mounts": [
+    "type=volume,source=iggy-cargo-registry,target=/usr/local/cargo/registry",
+    "type=volume,source=iggy-target,target=/workspaces/iggy/target"
+  ],
+  "containerEnv": {
+    "CARGO_BUILD_JOBS": "4",
+    "IGGY_HTTP_ADDRESS": "0.0.0.0:3000",
+    "IGGY_QUIC_ADDRESS": "0.0.0.0:8080",
+    "IGGY_TCP_ADDRESS": "0.0.0.0:8090",
+    "IGGY_WEBSOCKET_ADDRESS": "0.0.0.0:8092"
+  },
+  "forwardPorts": [3000, 3050, 8080, 8090, 8092],
+  "portsAttributes": {
+    "3000": { "label": "HTTP (REST)" },
+    "3050": { "label": "Web UI (vite dev)" },
+    "8080": { "label": "QUIC" },
+    "8090": { "label": "TCP (binary)" },
+    "8092": { "label": "WebSocket" }
+  },
+  "postCreateCommand": "sudo chown vscode:vscode target /usr/local/cargo/registry; rustup show && npm --prefix web ci && bash /workspaces/iggy/.devcontainer/notice.sh",
+  "customizations": {
+    "vscode": {
+      "extensions": [
+        "rust-lang.rust-analyzer",
+        "tamasfe.even-better-toml",
+        "vadimcn.vscode-lldb",
+        "svelte.svelte-vscode",
+        "ms-azuretools.vscode-docker"
+      ],
+      "settings": {
+        "rust-analyzer.cargo.buildScripts.enable": true,
+        "rust-analyzer.procMacro.enable": true,
+        "rust-analyzer.numThreads": 4,
+        "rust-analyzer.cargo.extraEnv": { "CARGO_BUILD_JOBS": "4" },
+        "editor.formatOnSave": true,
+        "[rust]": {
+          "editor.defaultFormatter": "rust-lang.rust-analyzer"
+        }
+      }
+    }
+  }
+}
diff --git a/.devcontainer/notice.sh b/.devcontainer/notice.sh
new file mode 100755
index 000000000..e04b40c35
--- /dev/null
+++ b/.devcontainer/notice.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Licenced under the Apache License, Version 2.0.
+
+set -euo pipefail
+
+RED=$'\033[0;31m'
+BOLD=$'\033[1m'
+NC=$'\033[0m'
+
+cat <<EOF
+
+${RED}${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}
+${BOLD}KNOWN LIMITATION: Docker-based bind-mount tests will fail in this devcontainer${NC}
+${RED}${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}
+
+This devcontainer uses docker-outside-of-docker: Docker commands inside the container
+talk to the host's Docker daemon via the Docker socket.
+
+The workspace is mounted at ${BOLD}/workspaces/iggy${NC} inside the container, but the host
+Docker daemon only knows the real host path (${BOLD}\${localWorkspaceFolder}${NC}).
+
+Bind mounts from compose files or testcontainers resolve to /workspaces/iggy/...,
+which the host daemon cannot reach.
+
+${BOLD}Affected tests:${NC}
+  - BDD tests:          ./scripts/run-bdd-tests.sh
+  - HTTP sink:          cargo test -p integration -- connectors::http
+  - HTTP config provider: cargo test -p integration -- connectors::http_config_provider
+
+${BOLD}Workarounds:${NC}
+  - Run affected tests on the host directly, outside the devcontainer
+  - Use native CI (GitHub Actions) where path translation is handled
+
+EOF
diff --git a/scripts/ci/sync-rustc-version.sh b/scripts/ci/sync-rustc-version.sh
index 386f10256..1d25027f6 100755
--- a/scripts/ci/sync-rustc-version.sh
+++ b/scripts/ci/sync-rustc-version.sh
@@ -182,15 +182,61 @@ for dockerfile in $DOCKERFILES; do
     fi
 done
 
+# ── devcontainer.json ──────────────────────────────────────────────
+#
+# devcontainer.json's `build.args` key is passed by VS Code as
+# `docker build --build-arg` and overrides the default value of
+# `ARG RUST_VERSION=1.96` in `.devcontainer/Dockerfile`.  When the key
+# is absent the Dockerfile's ARG default wins and no sync is needed.
+# When present it must match rust-toolchain.toml, otherwise the
+# devcontainer image can silently drift from the pinned toolchain.
+DEVCONTAINER_JSON=".devcontainer/devcontainer.json"
+
+check_devcontainer_json() {
+    if [ ! -f "$DEVCONTAINER_JSON" ]; then
+        return 0
+    fi
+
+    local current_version
+    current_version=$(jq -r '(.build.args.RUST_VERSION // .build.args.rust_version // "")' "$DEVCONTAINER_JSON" 2>/dev/null || true)
+    if [ -z "$current_version" ] || [ "$current_version" = "null" ]; then
+        return 0
+    fi
+
+    TOTAL_FILES=$((TOTAL_FILES + 1))
+
+    if [ "$MODE" = "check" ]; then
+        if [ "$current_version" != "$RUST_VERSION_SHORT" ]; then
+            MISALIGNED_FILES+=("$DEVCONTAINER_JSON")
+            echo -e "${RED}✗${NC} $DEVCONTAINER_JSON: build.args.RUST_VERSION ${RED}$current_version${NC} (expected: ${GREEN}$RUST_VERSION_SHORT${NC})"
+        else
+            echo -e "${GREEN}✓${NC} $DEVCONTAINER_JSON: build.args.RUST_VERSION ${GREEN}$RUST_VERSION_SHORT${NC}"
+        fi
+    elif [ "$MODE" = "fix" ]; then
+        if [ "$current_version" != "$RUST_VERSION_SHORT" ]; then
+            local tmp_file
+            tmp_file=$(mktemp)
+            jq --arg v "$RUST_VERSION_SHORT" '.build.args.RUST_VERSION = $v' "$DEVCONTAINER_JSON" > "$tmp_file"
+            mv "$tmp_file" "$DEVCONTAINER_JSON"
+            FIXED_FILES=$((FIXED_FILES + 1))
+            echo -e "${GREEN}Fixed${NC} $DEVCONTAINER_JSON: build.args.RUST_VERSION ${RED}$current_version${NC} -> ${GREEN}$RUST_VERSION_SHORT${NC}"
+        else
+            echo -e "${GREEN}✓${NC} $DEVCONTAINER_JSON: build.args.RUST_VERSION already correct (${GREEN}$RUST_VERSION_SHORT${NC})"
+        fi
+    fi
+}
+
+check_devcontainer_json
+
 echo ""
 echo "────────────────────────────────────────────────"
 
 if [ "$MODE" = "check" ]; then
     if [ ${#MISALIGNED_FILES[@]} -eq 0 ]; then
-        echo -e "${GREEN}✓ All $TOTAL_FILES Dockerfiles are aligned with Rust version $RUST_VERSION_SHORT${NC}"
+        echo -e "${GREEN}✓ All $TOTAL_FILES files are aligned with Rust version $RUST_VERSION_SHORT${NC}"
         exit 0
     else
-        echo -e "${RED}✗ Found ${#MISALIGNED_FILES[@]} misaligned Dockerfile(s) out of $TOTAL_FILES:${NC}"
+        echo -e "${RED}✗ Found ${#MISALIGNED_FILES[@]} misaligned file(s) out of $TOTAL_FILES:${NC}"
         for file in "${MISALIGNED_FILES[@]}"; do
             echo -e "  ${RED}• $file${NC}"
         done
@@ -200,9 +246,9 @@ if [ "$MODE" = "check" ]; then
     fi
 elif [ "$MODE" = "fix" ]; then
     if [ $FIXED_FILES -eq 0 ]; then
-        echo -e "${GREEN}✓ All $TOTAL_FILES Dockerfiles were already aligned with Rust version $RUST_VERSION_SHORT${NC}"
+        echo -e "${GREEN}✓ All $TOTAL_FILES files were already aligned with Rust version $RUST_VERSION_SHORT${NC}"
     else
-        echo -e "${GREEN}✓ Fixed $FIXED_FILES out of $TOTAL_FILES Dockerfiles to use Rust version $RUST_VERSION_SHORT${NC}"
+        echo -e "${GREEN}✓ Fixed $FIXED_FILES out of $TOTAL_FILES files to use Rust version $RUST_VERSION_SHORT${NC}"
     fi
     exit 0
 fi