mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
Layer the frontend toolchain on top of the existing release builder image so a single container covers Go, C support-layer and web development, with the builder image remaining the single source of truth for the cross toolchain, Go and MaixCDK. - Mount the workspace at /home/build/NanoKVM, where the Makefile and support/sg2002/build expect it, and resync MaixCDK components via update_lib on create so C builds never use stale sources - Install Node from official dist tarballs (integrity-checked, pinned to the major used by CI), with NODE_DIST_MIRROR / NPM_REGISTRY / BASE_IMAGE build args for restrictive or mirrored corporate networks - Export the MaixCDK virtualenv via remoteEnv so non-interactive processes (tasks, extensions, exec) get it too; make updateRemoteUserUID explicit since the published builder image bakes the CI runner's uid - Run pnpm non-interactively during post-create (no TTY) and give the skeleton-less home a standard ~/.profile -> ~/.bashrc chain - Make the web toolchain convention explicit via package.json engines (Node >= 22, pnpm >= 11, matching CI) and document it in web/README - Document the dev container in the README, point server/README at the container flow that works on any host OS, and ignore .pnpm-store/
53 lines
2.4 KiB
Docker
53 lines
2.4 KiB
Docker
# Dev container image for VS Code / the devcontainer CLI.
|
|
#
|
|
# The release builder image (docker/Dockerfile) stays the single source of
|
|
# truth for the RISC-V cross toolchain, Go and MaixCDK. This layer only adds
|
|
# the frontend toolchain on top: the builder image deliberately ships without
|
|
# Node (`make web` runs on the host), but an IDE container should cover web
|
|
# development as well.
|
|
#
|
|
# BASE_IMAGE can be overridden to a locally built builder image, e.g. the
|
|
# output of `make builder-image` (nanokvm-builder-local-<uid>-<gid>).
|
|
ARG BASE_IMAGE=ghcr.io/sipeed/nanokvm-builder:latest
|
|
FROM ${BASE_IMAGE}
|
|
|
|
USER root
|
|
|
|
# Node major and pnpm major track .github/workflows/package.yml ("Set up
|
|
# Node" / "Set up pnpm") and web/package.json "engines" -- keep all of them
|
|
# in sync when CI bumps either.
|
|
ARG NODE_MAJOR=22
|
|
ARG PNPM_VERSION=11
|
|
# Both can be overridden behind restrictive or mirrored corporate networks
|
|
# via devcontainer.json, e.g.:
|
|
# "build": {"args": {
|
|
# "NODE_DIST_MIRROR": "https://registry.npmmirror.com/-/binary/node",
|
|
# "NPM_REGISTRY": "https://registry.npmmirror.com"
|
|
# }}
|
|
ARG NODE_DIST_MIRROR=https://nodejs.org/dist
|
|
ARG NPM_REGISTRY=https://registry.npmjs.org
|
|
|
|
# Install the latest Node of the pinned major from official dist tarballs;
|
|
# tracking the latest patch release is intentional (rebuild the container to
|
|
# pick up updates). The SHA-256 check guards download integrity -- it shares
|
|
# its origin with the tarball, so it is not an authenticity proof.
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y ca-certificates curl xz-utils; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
case "$(uname -m)" in \
|
|
x86_64) node_arch=x64 ;; \
|
|
aarch64) node_arch=arm64 ;; \
|
|
*) echo "unsupported architecture: $(uname -m)" >&2; exit 1 ;; \
|
|
esac; \
|
|
curl -fsSL "${NODE_DIST_MIRROR}/latest-v${NODE_MAJOR}.x/SHASUMS256.txt" \
|
|
-o /tmp/SHASUMS256.txt; \
|
|
tarball="$(grep -o "node-v[0-9.]*-linux-${node_arch}\.tar\.xz" /tmp/SHASUMS256.txt | head -n1)"; \
|
|
curl -fsSL "${NODE_DIST_MIRROR}/latest-v${NODE_MAJOR}.x/${tarball}" -o "/tmp/${tarball}"; \
|
|
cd /tmp && grep " ${tarball}\$" SHASUMS256.txt | sha256sum -c -; \
|
|
tar -xJf "/tmp/${tarball}" -C /usr/local --strip-components=1 --no-same-owner; \
|
|
rm -f "/tmp/${tarball}" /tmp/SHASUMS256.txt; \
|
|
node --version && npm --version
|
|
RUN npm install --global --registry "${NPM_REGISTRY}" "pnpm@${PNPM_VERSION}" \
|
|
&& pnpm --version
|