Dockerfile-plugins 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright 2021 EMQ Technologies Co., Ltd.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. FROM golang:1.15.1 AS builder
  15. ARG VERSION
  16. ARG PLUGIN_TYPE
  17. ARG PLUGIN_NAME
  18. COPY . /go/kuiper
  19. WORKDIR /go/kuiper
  20. RUN set -e -u -x \
  21. && apt-get update \
  22. && apt-get install -y pkg-config libczmq-dev jq zip --assume-yes apt-utils
  23. RUN set -e -u -x \
  24. && mkdir -p _plugins/$PLUGIN_TYPE/$PLUGIN_NAME \
  25. && for lib in $(cat etc/$PLUGIN_TYPE/$PLUGIN_NAME.json | jq -r ".libs[]"); do go get $lib; done \
  26. && case $PLUGIN_NAME in \
  27. influxdb ) \
  28. go build -trimpath -modfile extensions.mod --buildmode=plugin -tags plugins -o plugins/$PLUGIN_TYPE/$PLUGIN_NAME/$PLUGIN_NAME@$VERSION.so extensions/$PLUGIN_TYPE/$PLUGIN_NAME/$PLUGIN_NAME.go \
  29. ;; \
  30. tdengine ) \
  31. if [ "$(uname -m)" = "x86_64" ]; then \
  32. wget "https://www.taosdata.com/download/download-all.php?pkgType=tdengine_linux&pkgName=TDengine-client-2.0.19.1-Linux-x64.tar.gz" -O /tmp/TDengine-client-2.0.19.1.tar.gz; \
  33. fi; \
  34. if [ "$(uname -m)" = "aarch64" ]; then \
  35. wget "https://www.taosdata.com/download/download-all.php?pkgType=tdengine_linux&pkgName=TDengine-client-2.0.19.1-Linux-aarch64.tar.gz" -O /tmp/TDengine-client-2.0.19.1.tar.gz; \
  36. fi; \
  37. tar -zxvf /tmp/TDengine-client-2.0.19.1.tar.gz \
  38. && cd TDengine-client-2.0.19.1 && ./install_client.sh && cd - \
  39. && go build -trimpath -modfile extensions.mod --buildmode=plugin -tags plugins -o plugins/$PLUGIN_TYPE/$PLUGIN_NAME/$PLUGIN_NAME@$VERSION.so extensions/$PLUGIN_TYPE/$PLUGIN_NAME/$PLUGIN_NAME.go \
  40. ;; \
  41. labelImage ) \
  42. git clone -b v2.2.0-rc3 --depth 1 https://github.com/tensorflow/tensorflow.git /tensorflow; \
  43. CGO_CFLAGS=-I/tensorflow CGO_LDFLAGS=-L/go/kuiper/extensions/functions/labelImage/lib go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/functions/labelImage/labelImage.so extensions/functions/labelImage/*.go \
  44. ;; \
  45. * ) \
  46. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/$PLUGIN_TYPE/$PLUGIN_NAME/$PLUGIN_NAME@$VERSION.so extensions/$PLUGIN_TYPE/$PLUGIN_NAME/*.go \
  47. ;; \
  48. esac \
  49. && if [ -f "etc/$PLUGIN_TYPE/$PLUGIN_NAME.yaml" ]; then cp etc/$PLUGIN_TYPE/$PLUGIN_NAME.yaml plugins/$PLUGIN_TYPE/$PLUGIN_NAME; fi \
  50. && cd plugins/$PLUGIN_TYPE/$PLUGIN_NAME \
  51. && zip -r ${PLUGIN_NAME}_$(go version | grep -o "linux/.*" | sed -r 's linux/(.*) \1 g').zip .