Files
devcontainers/Makefile
2026-02-14 17:14:52 +08:00

27 lines
889 B
Makefile

# 切换到 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
# 目录构建规则
$(SUBDIRS):
@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 $(SUBDIRS)