久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <small id='WDWW4'></small><noframes id='WDWW4'>

          <bdo id='WDWW4'></bdo><ul id='WDWW4'></ul>
      1. <tfoot id='WDWW4'></tfoot><legend id='WDWW4'><style id='WDWW4'><dir id='WDWW4'><q id='WDWW4'></q></dir></style></legend>

        <i id='WDWW4'><tr id='WDWW4'><dt id='WDWW4'><q id='WDWW4'><span id='WDWW4'><b id='WDWW4'><form id='WDWW4'><ins id='WDWW4'></ins><ul id='WDWW4'></ul><sub id='WDWW4'></sub></form><legend id='WDWW4'></legend><bdo id='WDWW4'><pre id='WDWW4'><center id='WDWW4'></center></pre></bdo></b><th id='WDWW4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WDWW4'><tfoot id='WDWW4'></tfoot><dl id='WDWW4'><fieldset id='WDWW4'></fieldset></dl></div>
      2. Maven docker緩存依賴

        Maven docker cache dependencies(Maven docker緩存依賴)
        <tfoot id='82SJp'></tfoot>
          <bdo id='82SJp'></bdo><ul id='82SJp'></ul>

          <small id='82SJp'></small><noframes id='82SJp'>

            <i id='82SJp'><tr id='82SJp'><dt id='82SJp'><q id='82SJp'><span id='82SJp'><b id='82SJp'><form id='82SJp'><ins id='82SJp'></ins><ul id='82SJp'></ul><sub id='82SJp'></sub></form><legend id='82SJp'></legend><bdo id='82SJp'><pre id='82SJp'><center id='82SJp'></center></pre></bdo></b><th id='82SJp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='82SJp'><tfoot id='82SJp'></tfoot><dl id='82SJp'><fieldset id='82SJp'></fieldset></dl></div>

                1. <legend id='82SJp'><style id='82SJp'><dir id='82SJp'><q id='82SJp'></q></dir></style></legend>

                    <tbody id='82SJp'></tbody>
                  本文介紹了Maven docker緩存依賴的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試使用 docker 來自動化 maven 構建.我要構建的項目需要將近20分鐘才能下載所有依賴項,所以我嘗試構建一個可以緩存這些依賴項的docker鏡像,但它似乎沒有保存它.我的 Dockerfile 是

                  I'm trying to use docker to automate maven builds. The project I want to build takes nearly 20 minutes to download all the dependencies, so I tried to build a docker image that would cache these dependencies, but it doesn't seem to save it. My Dockerfile is

                  FROM maven:alpine
                  RUN mkdir -p /usr/src/app
                  WORKDIR /usr/src/app
                  ADD pom.xml /usr/src/app
                  RUN mvn dependency:go-offline
                  

                  鏡像生成,它會下載所有內容.但是,生成的圖像與基本 maven:alpine 圖像大小相同,因此它似乎沒有緩存圖像中的依賴項.當我嘗試使用該圖像來 mvn compile 時,它會經歷整整 20 分鐘的重新下載所有內容.

                  The image builds, and it does download everything. However, the resulting image is the same size as the base maven:alpine image, so it doesn't seem to have cached the dependencies in the image. When I try to use the image to mvn compile it goes through the full 20 minutes of redownloading everything.

                  是否可以構建一個緩存我的依賴項的 maven 映像,這樣我每次使用該映像執行構建時就不必下載它們?

                  Is it possible to build a maven image that caches my dependencies so they don't have to download everytime I use the image to perform a build?

                  我正在運行以下命令:

                  docker build -t my-maven .
                  
                  docker run -it --rm --name my-maven-project -v "$PWD":/usr/src/mymaven -w /usr/src/mymaven my-maven mvn compile
                  

                  我的理解是 RUN 在 docker 構建過程中所做的任何事情都會成為結果圖像的一部分.

                  My understanding is that whatever RUN does during the docker build process becomes part of the resulting image.

                  推薦答案

                  通常,pom.xml 文件沒有變化,只是在您嘗試啟動 docker image 時其他一些源代碼發生了變化建造.在這種情況下,您可以這樣做:

                  Usually, there's no change in pom.xml file but just some other source code changes when you're attempting to start docker image build. In such circumstance you can do this:

                  僅供參考:

                  FROM maven:3-jdk-8
                  
                  ENV HOME=/home/usr/app
                  
                  RUN mkdir -p $HOME
                  
                  WORKDIR $HOME
                  
                  # 1. add pom.xml only here
                  
                  ADD pom.xml $HOME
                  
                  # 2. start downloading dependencies
                  
                  RUN ["/usr/local/bin/mvn-entrypoint.sh", "mvn", "verify", "clean", "--fail-never"]
                  
                  # 3. add all source code and start compiling
                  
                  ADD . $HOME
                  
                  RUN ["mvn", "package"]
                  
                  EXPOSE 8005
                  
                  CMD ["java", "-jar", "./target/dist.jar"]
                  

                  所以關鍵是:

                  1. 添加 pom.xml 文件.

                  然后mvn verify --fail-never,它會下載maven依賴.

                  then mvn verify --fail-never it, it will download maven dependencies.

                  然后添加所有源文件,然后開始編譯(mvn package).

                  add all your source file then, and start your compilation(mvn package).

                  當你的 pom.xml 文件有變化或者你是第一次運行這個腳本時,docker 會做 1 -> 2 -> 3.當沒有變化時在pom.xml文件中,docker會跳過第1、2步,直接做第3步.

                  When there are changes in your pom.xml file or you are running this script for the first time, docker will do 1 -> 2 -> 3. When there are no changes in pom.xml file, docker will skip step 1、2 and do 3 directly.

                  這個簡單的技巧可以用于許多其他包管理環境(gradle、yarn、npm、pip).

                  This simple trick can be used in many other package management circumstances(gradle、yarn、npm、pip).

                  您還應該考慮使用 mvn dependency:resolvemvn dependency:go-offline 相應地作為其他注釋 &答案建議.

                  You should also consider using mvn dependency:resolve or mvn dependency:go-offline accordingly as other comments & answers suggest.

                  這篇關于Maven docker緩存依賴的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                      <legend id='Zsuwx'><style id='Zsuwx'><dir id='Zsuwx'><q id='Zsuwx'></q></dir></style></legend>
                        <tfoot id='Zsuwx'></tfoot>
                        <i id='Zsuwx'><tr id='Zsuwx'><dt id='Zsuwx'><q id='Zsuwx'><span id='Zsuwx'><b id='Zsuwx'><form id='Zsuwx'><ins id='Zsuwx'></ins><ul id='Zsuwx'></ul><sub id='Zsuwx'></sub></form><legend id='Zsuwx'></legend><bdo id='Zsuwx'><pre id='Zsuwx'><center id='Zsuwx'></center></pre></bdo></b><th id='Zsuwx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Zsuwx'><tfoot id='Zsuwx'></tfoot><dl id='Zsuwx'><fieldset id='Zsuwx'></fieldset></dl></div>
                            <tbody id='Zsuwx'></tbody>

                          <small id='Zsuwx'></small><noframes id='Zsuwx'>

                            <bdo id='Zsuwx'></bdo><ul id='Zsuwx'></ul>
                          • 主站蜘蛛池模板: 日韩欧美一级片 | 91久久精品国产91久久性色tv | 在线看av网址 | 日本亚洲一区 | 免费的网站www | 蜜桃久久 | 99伊人 | 国产一区二区三区四区在线观看 | 日韩欧美国产一区二区 | 久久久久亚洲av毛片大全 | 国产精品一区二区av | 国产欧美日韩一区二区三区在线 | 国产精品久久久久久久久久 | 视频在线一区二区 | 国产精品久久久久久吹潮日韩动画 | 在线成人免费视频 | 日日躁狠狠躁aaaaxxxx | 久久久久久亚洲精品不卡 | h片免费在线观看 | 日本 欧美 三级 高清 视频 | 国产一区二区欧美 | 国产精品不卡 | 视频精品一区二区三区 | 日韩一区二区在线看 | 欧美日韩国产一区二区三区 | 亚洲电影第1页 | 玖玖玖在线| 免费观看www7722午夜电影 | 国产一区 在线视频 | 久久久免费观看视频 | 成人一区在线观看 | 国产精品成人一区 | h片在线观看免费 | 亚洲女人的天堂 | 少妇久久久 | 黄色片大全在线观看 | 中文字幕在线观看视频一区 | 日韩视频精品在线 | 日韩一区二区三区在线观看 | 国产精品久久久久久影视 | 欧洲毛片|