簡體   English   中英

Clojure AWS Lambda Function目標中的OpenCV大於250MB,如何減小它的大小?

[英]OpenCV in Clojure AWS Lambda Function target is larger than 250MB, how do I reduce it's size?

我正在嘗試使用lein-lambda通過折紙使用OpenCV https://opencv.org/進行部署。 但是我的target/目錄最終為350Mb,而lambda要求未壓縮的上傳最大為250Mb。

如果我看target/

$ tree -L 2 target/
target/
├── classes
│   ├── META-INF
│   ├── cheshire
│   ├── clj_time
│   ├── clojure
│   ├── clout
│   ├── compojure
│   ├── crypto
│   ├── detect-features
│   ├── detect_features
│   ├── instaparse
│   ├── medley
│   ├── opencv3
│   ├── ring
│   └── uswitch
├── clj-opencv-0.1-SNAPSHOT-standalone.jar
├── clj-opencv-0.1-SNAPSHOT.jar
├── native
│   ├── linux
│   ├── macosx
│   └── windows
└── stale
    └── leiningen.core.classpath.extract-native-dependencies

我注意到,還有用於macosxwindows OpenCV構建。 如果我可以在lein lambda deploy production命令期間刪除這些構建,那么它應該足夠小。

這是我的project.clj文件,可能已實現到uberjar

(defproject clj-opencv "0.1-SNAPSHOT"
  :description "Identify key points and edges to use for good looking Delauney triangulation."
  :url "https://www.example.com/TODO"
  :min-lein-version "2.0.0"
  :injections [(clojure.lang.RT/loadLibrary org.opencv.core.Core/NATIVE_LIBRARY_NAME)]
  :test-paths ["test"]
  :resource-paths ["rsc"]
  :plugins [[lein-gorilla "0.4.0"]
            [lein-auto "0.1.3"]
            [lein-ring "0.9.7"]
            [lein-lambda "0.2.0"]]
  :auto {:default {:file-pattern #"\.(clj)$"}}
  :repositories [["vendredi" "https://repository.hellonico.info/repository/hellonico/"]]
  :aliases {"notebook" ["gorilla" ":ip" "0.0.0.0" ":port" "10000"]}
  :profiles {:dev {:resource-paths ["resources"]
                   :dependencies [; used for proto repl
                                  [org.clojure/tools.nrepl "0.2.11"]
                                  ; proto repl
                                  [proto-repl "0.3.1"]
                                  ; use to start a gorilla repl
                                  [gorilla-repl "0.4.0"]
                                  [seesaw "1.4.5"]
                                  ; aws lambda
                                  [javax.servlet/servlet-api "2.5"]
                                  [ring/ring-mock "0.3.1"]]}
             :uberjar {:aot :all}}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/tools.cli "0.3.5"]
                 [origami "0.1.10"]
                 [compojure "1.6.0"]
                 [ring/ring-defaults "0.3.1"]
                 [ring/ring-json "0.4.0"]
                 [uswitch/lambda "0.1.2"]
                 [cheshire "5.7.1"]
                 [ring-apigw-lambda-proxy "0.3.0"]
                 [feedme "0.0.3"]
                 [clj-spotify "0.1.5"]
                 [rotary "0.4.1"]]
  :ring {:handler detect-features.handler/app}
  :lambda {:function {:name "lowpoly-detect-features" ; bucket name cannot contain underscores
                      :handler "detect-features.lambda.LambdaFn"}
           :api-gateway {:name "detect-features"}
           :stages {"production" {:warmup {:enable true}}
                    "staging"    {}}}
  ; For local runs. Probably needs to be off in projection.
  :main detect-features.lambda)

只需使用jar-exclusions:

:jar-exclusions [#"^docs/.*" #"^public/js/.*" #"^example-data/.*"]

我不知道lein-lambda是如何工作的(如果它上載了jar或uberjar,這應該是您的首要任務),但是我想提醒您注意不同的方法:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM