From 3b381be4da59ebd938bdf8248df31cf2ea535aee Mon Sep 17 00:00:00 2001 From: QXYang686 Date: Sat, 14 Feb 2026 16:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9E=84=E5=BB=BA=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 33 +++++++++++++++++++++++++++++++++ system-setup.sh | 22 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Makefile create mode 100644 system-setup.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b360e5b --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# 切换到 bash +SHELL := /bin/bash + +# 定义变量 +REGISTRY_LOCAL ?= localhost:5000 +REGISTRY ?= crpi-kbfsbvlqwt19zxum-vpc.cn-hongkong.personal.cr.aliyuncs.com/registry-yqxpro +GIT_SHA := $(shell git rev-parse --short HEAD) + +# 定义所有需要构建的子目录 +SUBDIRS = common-base develop-base universal-base + +# 默认目标:按顺序构建所有子目录 +all: $(SUBDIRS) + +# 模式规则:每个目录目标都依赖对应的目录 +%: %/ + @echo "Building $@ Finished" + +# 目录构建规则 +%/: + @echo "Building $@..." + @pushd $@ && \ + npx devcontainer build \ + --platform linux/amd64,linux/arm64 \ + --image-name $(REGISTRY_LOCAL)/devcontainers/$@ --push \ + --cache-to type=registry,ref=$(REGISTRY_LOCAL)/devcontainers/$@:buildcache,mode=max \ + --cache-from type=registry,ref=$(REGISTRY_LOCAL)/devcontainers/$@:buildcache && \ + docker tag $(REGISTRY_LOCAL)/devcontainers/$@ $(REGISTRY)/devcontainers/$@:$(GIT_SHA) && \ + docker push $(REGISTRY)/devcontainers/$@:$(GIT_SHA) && \ + popd + +# 伪目标声明 +.PHONY: all parallel clean $(SUBDIRS) diff --git a/system-setup.sh b/system-setup.sh new file mode 100644 index 0000000..3c4fc40 --- /dev/null +++ b/system-setup.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +export REGISTRY_USERNAME=qxyang686@qq.com +export REGISTRY_PASSWORD= +export REGISTRY_HOST=crpi-kbfsbvlqwt19zxum-vpc.cn-hongkong.personal.cr.aliyuncs.com +export REGISTRY=crpi-kbfsbvlqwt19zxum-vpc.cn-hongkong.personal.cr.aliyuncs.com/registry-yqxpro + +sudo apt update +sudo apt install -y npm git +curl -fsSL https://raw.githubusercontent.com/docker/docker-install/master/install.sh | sh +sudo usermod -aG docker $USER +docker buildx create --use --name multiarch-builder +docker login --username=$REGISTRY_USERNAME --password=$REGISTRY_PASSWORD $REGISTRY_HOST + +docker run -d \ + -p 5000:5000 \ + --name registry \ + registry:3 + +git clone https://gitea.yqxpro.com/QXYang686/devcontainers.git +cd devcontainers +npm install