feat: 使用多阶段构建优化 wasm-go 构建流程 (#192)

This commit is contained in:
悟空
2023-02-24 12:26:31 +08:00
committed by GitHub
parent e839052a9e
commit bd381b3536
5 changed files with 179 additions and 72 deletions

View File

@@ -4,17 +4,29 @@ BUILD_TIME := $(shell date "+%Y%m%d-%H%M%S")
COMMIT_ID := $(shell git rev-parse --short HEAD 2>/dev/null)
IMG ?= ${REGISTRY}${PLUGIN_NAME}:${BUILD_TIME}-${COMMIT_ID}
.DEFAULT:
build:
DOCKER_BUILDKIT=1 docker build --build-arg PLUGIN_NAME=${PLUGIN_NAME} \
--build-arg THIS_ARCH=${THIS_ARCH} \
--build-arg GO_VERSION=${GO_VERSION} \
--build-arg TINYGO_VERSION=${TINYGO_VERSION} \
-t ${IMG} \
-f DockerfileBuilder \
--output extensions/${PLUGIN_NAME} .
-t ${IMG} \
--output extensions/${PLUGIN_NAME} \
.
@echo ""
@echo "image: ${IMG}"
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"
build-push: build
docker push ${IMG}
docker push ${IMG}
# builder:
# To build a wasm-go-builder image.
# If you want to use Go/TinyGo with another version, please modify GO_VERSION/TINYGO_VERSION.
# After your wasm-go-builder image is built, you can use --build-arg BUILDER=<your-wasm-go-builder> to build plugin image.
builder:
docker buildx build --platform linux/amd64,linux/arm64 \
--build-arg BASE_IMAGE=docker.io/ubuntu \
--build-arg GO_VERSION=1.19 \
--build-arg TINYGO_VERSION=0.26.0 \
-f DockerfileBuilder \
-t wasm-go-builder:go1.19-tinygo0.26.0 \
--push \
.