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/
38 lines
1.5 KiB
Bash
Executable File
38 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs once inside the dev container after it is created (see
|
|
# .devcontainer/devcontainer.json). Keeps the container aligned with the
|
|
# CLI flow in the Makefile and scripts/build-in-container.sh.
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
# The MaixCDK components baked into the image can be older than this
|
|
# checkout; resync them so C builds never use stale sources (same reason
|
|
# scripts/build-in-container.sh runs update_lib first).
|
|
"$repo_root/support/sg2002/build" update_lib
|
|
|
|
# Frontend dependencies. postCreate has no TTY, and CI=true lets pnpm make
|
|
# its non-interactive choices -- e.g. purging a node_modules tree that was
|
|
# installed from the host OS through the bind mount.
|
|
(cd "$repo_root/web" && CI=true pnpm install --frozen-lockfile)
|
|
|
|
# Start every interactive shell with the MaixCDK virtualenv active,
|
|
# mirroring `make shell`.
|
|
activate_line='. "$HOME/MaixCDK/bin/activate"'
|
|
if ! grep -qxF "$activate_line" "$HOME/.bashrc" 2>/dev/null; then
|
|
printf '\n# MaixCDK virtualenv (added by .devcontainer/post-create.sh)\n%s\n' \
|
|
"$activate_line" >>"$HOME/.bashrc"
|
|
fi
|
|
|
|
# The build user's home has no shell skeleton files (useradd ran with
|
|
# --no-create-home), so login shells would skip ~/.bashrc; give them the
|
|
# standard Debian chain.
|
|
if [ ! -f "$HOME/.profile" ]; then
|
|
cat >"$HOME/.profile" <<'EOF'
|
|
# ~/.profile (added by .devcontainer/post-create.sh)
|
|
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ]; then
|
|
. "$HOME/.bashrc"
|
|
fi
|
|
EOF
|
|
fi
|