Skip to content

Commit

Permalink
feat: support use docker image to build cpp wasmplugin at local
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinsteny committed Jul 21, 2023
1 parent aa17e95 commit cb89619
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugins/wasm-cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG BUILDER=higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/build-tools-proxy:release-1.12-2021-12-09T23-01-43
FROM $BUILDER as builder

ARG PLUGIN_NAME

WORKDIR /workspace

COPY . .

RUN bazel build //extensions/$PLUGIN_NAME:$PLUGIN_NAME.wasm

FROM scratch as output

ARG PLUGIN_NAME

COPY --from=builder /workspace/bazel-bin/extensions/$PLUGIN_NAME/$PLUGIN_NAME.wasm plugin.wasm
14 changes: 14 additions & 0 deletions plugins/wasm-cpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PLUGIN_NAME ?= key_auth
BUILD_TIME := $(shell date "+%Y%m%d-%H%M%S")
COMMIT_ID := $(shell git rev-parse --short HEAD 2>/dev/null)
IMAGE_TAG = $(if $(strip $(PLUGIN_VERSION)),${PLUGIN_VERSION},${BUILD_TIME}-${COMMIT_ID})
IMG ?= ${REGISTRY}${PLUGIN_NAME}:${IMAGE_TAG}

.PHONY: build
build:
DOCKER_BUILDKIT=1 docker build --build-arg PLUGIN_NAME=${PLUGIN_NAME} \
-t ${IMG} \
--output extensions/${PLUGIN_NAME} \
.
@echo ""
@echo "output wasm file: extensions/${PLUGIN_NAME}/plugin.wasm"

0 comments on commit cb89619

Please sign in to comment.