Browse Source

fix(ci): support plugin for alpine image (#1371)

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
superxan 2 years ago
parent
commit
155d14c4c8

+ 12 - 5
.github/workflows/build_packages.yaml

@@ -195,11 +195,18 @@ jobs:
         arch:
           - linux/amd64
           - linux/arm64
+        os:
+          - [debian, "slim"]
+          - [alpine, "alpine"]
         golang:
           - 1.18.5
         exclude:
           - arch: linux/arm64
             plugin: functions/labelImage
+          - os: [alpine,"alpine"]
+            plugin: functions/labelImage
+          - os: [alpine,"alpine"]
+            plugin: sinks/tdengine
 
     steps:
     - uses: actions/checkout@v2
@@ -210,13 +217,13 @@ jobs:
       with:
         image: tonistiigi/binfmt:latest
         platforms: all
-    - name: build debian plugins
+    - name: build plugins
       run: |
         docker run -i --rm \
             -v $(pwd):/ekuiper \
             --workdir /ekuiper \
             --platform ${{ matrix.arch }} \
-            ghcr.io/lf-edge/ekuiper/base:${{ matrix.golang }}-debian \
+            ghcr.io/lf-edge/ekuiper/base:${{ matrix.golang }}-${{ matrix.os[0] }} \
             bash -euc "make ${{ matrix.plugin }}"
     - name: Build ekuiper image
       uses: docker/build-push-action@v2
@@ -226,8 +233,8 @@ jobs:
         platforms: linux/amd64
         push: false
         load: true
-        tags: docker.io/lfedge/ekuiper
-        file: deploy/docker/Dockerfile-slim
+        tags: docker.io/lfedge/ekuiper-${{ matrix.os[0] }}
+        file: deploy/docker/Dockerfile-${{ matrix.os[1] }}
     - name: test docker and plugins
       if: matrix.arch == 'linux/amd64'
       env:
@@ -237,7 +244,7 @@ jobs:
         plugin_type=$(echo ${PLUGIN%%/*})
         plugin_name=$(echo ${PLUGIN##*/})
 
-        container_id=$(docker run -d -v $(pwd)/_plugins:/var/plugins docker.io/lfedge/ekuiper)
+        container_id=$(docker run -d -v $(pwd)/_plugins:/var/plugins docker.io/lfedge/ekuiper-${{ matrix.os[0] }})
         ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_id)
         os=$(docker exec -i ${container_id} sh -c "sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g'" )
         sleep 5

+ 3 - 2
build-plugins.sh

@@ -6,9 +6,10 @@ cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")"
 PLUGIN_TYPE=$1
 PLUGIN_NAME=$2
 VERSION=$(git describe --tags --always)
+OS=$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g')
 
 pre(){
-    mkdir -p _plugins/debian/$PLUGIN_TYPE
+    mkdir -p _plugins/$OS/$PLUGIN_TYPE
     if [  $(cat etc/$PLUGIN_TYPE/$PLUGIN_NAME.json | jq -r ".libs") != 'null' ]; then
         for lib in $(cat etc/$PLUGIN_TYPE/$PLUGIN_NAME.json | jq -r ".libs[]"); do
             go get $lib;
@@ -23,7 +24,7 @@ post(){
     cd extensions/$PLUGIN_TYPE/$PLUGIN_NAME
     zip -r ${PLUGIN_NAME}_$(go env GOARCH).zip .
     cd -
-    mv $(find extensions/$PLUGIN_TYPE/$PLUGIN_NAME -name "*.zip")  _plugins/debian/$PLUGIN_TYPE
+    mv $(find extensions/$PLUGIN_TYPE/$PLUGIN_NAME -name "*.zip")  _plugins/$OS/$PLUGIN_TYPE
 }
 
 build(){

+ 1 - 3
deploy/docker/Dockerfile

@@ -19,9 +19,7 @@ COPY . /go/kuiper
 
 WORKDIR /go/kuiper
 
-RUN apt-get update \
-    && apt-get install -y pkg-config libczmq-dev wget \
-    && apt-get clean \
+RUN apt-get clean \
     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
 RUN make build_with_edgex \

+ 1 - 2
deploy/docker/Dockerfile-alpine

@@ -13,13 +13,12 @@
 # limitations under the License.
 
 ARG GO_VERSION=1.18.5
-FROM golang:$GO_VERSION-alpine AS builder
+FROM ghcr.io/lf-edge/ekuiper/base:$GO_VERSION-alpine AS builder
 
 COPY . /go/kuiper
 
 WORKDIR /go/kuiper
 
-RUN apk add gcc make git libc-dev binutils-gold pkgconfig zeromq-dev 
 RUN make build_with_edgex
 
 FROM alpine:3.15

+ 0 - 1
deploy/docker/Dockerfile-slim

@@ -19,7 +19,6 @@ COPY . /go/kuiper
 
 WORKDIR /go/kuiper
 
-RUN apt update && apt install -y pkg-config libczmq-dev
 RUN make build_with_edgex
 
 FROM debian:buster-20211011 

+ 0 - 1
deploy/docker/Dockerfile-slim-python

@@ -19,7 +19,6 @@ COPY . /go/kuiper
 
 WORKDIR /go/kuiper
 
-RUN apt update && apt install -y pkg-config libczmq-dev
 RUN make build_with_edgex
 
 FROM python:3.8.12-slim-bullseye