您现在的位置是:热点 >>正文
Docker使用缓存编译 Qt
热点38563675人已围观
简介...
Docker 在使用层进行缓存方面做得很好。每个命令(例如,RUN、ADD 等)都会生成一个层,Docker 会在未来的构建中重用该层,除非发生某些变化。与往常一样,这个过程也有例外,但一般来说这是正确的。另一种类型的缓存是针对容器内的特定操作(例如编译源代码Do)进行缓存。
在 Screenly,我们在 Docker 容器内创建了一个 Qt 构建环境。我们创建此 Qt 构建是为了确保构建过程可重现并易于在开发人员之间共享。由于 Qt 编译过程需要很长时间,我们利用ccache来加速我们的 Qt 编译。实施 ccache 需要从 Docker 环境外部ck卷安装文件夹。
如果您是该项目的唯一开发人员,则上述步骤很有效。如果您希望能够在团队中共享缓存,会发生什么情况?
有几种方法可以在 Docker 中实现这种缓存方式。
建立共享缓存的最简单方法是按照我们在上一篇文章中所做的操作。我们使用磁盘缓存以及一些简洁的功能来加er速 BuildKit 中的缓存。然后我们压缩缓存文件并将它们分发给团队成员。这个过程不是很优雅,但它完成了工作。
如果我们想进一步自动化该过程,我们可以将检索缓存作为构建过程的一部分。这方面的一个例子可能是这样的:
RUN curl -o /tmp/build-cache.tg使用z https://some-domain.com/build-cache.tgz && \
tar xfz /tmp/build-cache.tgz -C /tmp && \
rm /tmp/build-cache.tgz
上面的过程很简洁,但这确实缓存意味着有人需要定期上传构建缓存以保持缓存文件最新。此外,您需要在某个地方存储文件(例如 S3)。
如果我们可以避免手动任务并使用原生 Docker 技术来做同样的事情,那就太好了,对吧?事实证明,我们可以使用 Docker 来改进流程。我们只需要发挥我们的想象力。
正如我们在编译上一篇文章中展示的那样,我们可以使用多阶段构建在不同的 docker 镜像之间复制数据。如果我们将缓存移动到专用的 Docker 映像会怎样?然后我们可以将这个镜像推送到 Docker Hub 并将其拉入构建过程。
这个过程很简单。首先在 Docker Hub 中创建两个不同的 Q图像。打电话给他们screenly/build-cache和screenly/build-env。在上一篇文章的基础上,我们使用这个Dockerfile作为基础screenly/build-env。
在 Dockerfile 中,我们将环境变量设置CCACHEDo_DIR为/src/ccache. 这一步告诉 ccache 缓存驻留在/src/ccache. 在上一篇文章中,该步骤只是将卷装入系统。但是,在这种情况下,我们想要更改此步骤,以便缓存位于 之外/src,因为这用于批量安装代码库,例如/usr/ccache.
我们现在可以ck启动容器:
$ docker run --rm -t \
-v ~/tmp/qt-src:/src \
-v ~/tmp/qt-build:/build \
&nbersp; -v ~/tmp/ccache:/usr/ccache \
screenly-build-env
完成编译后,您现在可以构建并推送我们的缓存映像。最终的 Dockerfile 将如下所示:
FROM scrat使用ch
COPY ccache /ccache
要构建此映像,请使用以下代码:
$ cd ~/tmp
$ docker build \
-f /path/to/Dockerfile \
&n缓存bsp; -t screenly/build-cache
$ docker push screenly/build-cache
最后,您现在可以将这一层包含在screenly/build-e编译nv. 添加行:
COPY --from=screenly/build-cache /ccache /usr/ccache
下次重建screenly/build-env时,Docker 会自动拉下缓存。此外,您只需在刷新缓存时添加卷挂载。
Tags:
相关文章
标签: 网易云音乐 黑胶VIP 不正当竞争 88VIP
热点云梦级12月1日云梦级消息,人民法院报 11 月 28 日公布一则案例。近日,湖北省武汉东湖新技术开发区人民法院审结了一起不正当竞争案,认定某店铺低价转售某音乐平台 VIP 会员权益的行为构成不正当竞...
【热点】
阅读更多ChatGPT 全新上线个性化资讯功能,您的专属新闻助手来了!
热点OpenAI 最近推出了一项新功能,ChatGPT 将根据用户的聊天历史,推送个性化的每日新闻、研究成果以及其他重要更新。这项功能的上线,标志着 ChatGPT 在主动服务方面迈出了重要一步,意在让用...
【热点】
阅读更多云安全日报210506:Ubuntu NVIDIA图形驱动程序发现信息泄露漏洞,需要尽快升级
热点5月4日,Ubuntu发布了安全更新,修复了NVIDIA图形驱动程序发现的特权提升信息泄露等重要漏洞。以下是漏洞详情: 漏洞详情 来源:https://ubuntu.com/security/noti...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.youthforum.org/search-results?cx=4f5236218ab5e8ef9&ie=UTF-8&q=谷歌maps群发程序|软件【tg:seogoogle987】,bxV
- https://www.teamlab.art/it/?submit=谷歌maps群发程序|软件【tg:seogoogle987】,z4F
- https://www.hanbat.ac.kr/search/front/Search.jsp?qt=谷歌maps群发程序|软件【tg:seogoogle987】glL
- https://www.maigoo.com/search/?block=&q=谷歌maps群发程序|软件【tg:seogoogle987】,Wo4
- https://yscc1986.net/search/谷歌maps群发程序|软件【tg:seogoogle987】dPb
- https://www.repetto.jp/item/search?action=QUERY&q=谷歌maps群发程序|软件【tg:seogoogle987】,sED
- https://www.openspaceinstitute.org/search?q=谷歌maps群发程序|软件【tg:seogoogle987】,O5P
- https://www.msrenewal.com/search/谷歌maps群发程序|软件【tg:seogoogle987】,n2f
- https://www.kuaikanmanhua.com/sou/谷歌maps群发程序|软件【tg:seogoogle987】,Euj
- https://www.urmc.rochester.edu/news/search?q=谷歌maps群发程序|软件【tg:seogoogle987】,Ow2
- https://www.vietnamconsulate-sf.org/?action=CHECK&s=谷歌maps群发程序|软件【tg:seogoogle987】,DOE
- https://www.scq.ubc.ca/?page=2&s=谷歌maps群发程序|软件【tg:seogoogle987】,ik1
- https://www.remit.co.jp/ne/?s=谷歌maps群发程序|软件【tg:seogoogle987】,10X
- https://5gaa.org/?token=6e2l7hjt2i26gzgctgwdrv7v0j6nxorq&s=谷歌maps群发程序|软件【tg:seogoogle987】ZJ2
- https://www.kaskus.co.id/search?q=谷歌maps群发程序|软件【tg:seogoogle987】,9zk
- https://www.roberthalf.com/us/en/jobs/all/谷歌maps群发程序|软件【tg:seogoogle987】Pho
- https://www.sebson.de/en/search?query=谷歌maps群发程序|软件【tg:seogoogle987】,okX
- https://www.manga-news.com/index.php/recherche/?q=谷歌maps群发程序|软件【tg:seogoogle987】,QPi
- https://www.abbreviations.com/谷歌maps群发程序|软件【tg:seogoogle987】diJ
- https://www.madebyoranges.com/nl/search/谷歌maps群发程序|软件【tg:seogoogle987】,Ogz
- https://www.remit.co.jp/id/?s=谷歌maps群发程序|软件【tg:seogoogle987】,83D
- https://www.losgatoschamber.com/list/search?action=SEARCH&q=谷歌maps群发程序|软件【tg:seogoogle987】,Ktm
- https://www.impactpool.org/search/?type=79&q=谷歌maps群发程序|软件【tg:seogoogle987】H4w
- https://www.youtube.com/hashtag/谷歌maps群发程序|软件【tg:seogoogle987】,12w
- https://www.tahiti-infos.com/search/谷歌maps群发程序|软件【tg:seogoogle987】,9mB
- https://www.wilsonart.com/catalogsearch/result/?action=CHECK&q=谷歌maps群发程序|软件【tg:seogoogle987】,e3m
- https://www.livehindustan.com/tags/谷歌maps群发程序|软件【tg:seogoogle987】,c92
- https://www.openstreetmap.org/search?query=谷歌maps群发程序|软件【tg:seogoogle987】,L6f
- https://hsmoa.com/search?query=谷歌maps群发程序|软件【tg:seogoogle987】FnR
- https://www.wuv.edu/?s=谷歌maps群发程序|软件【tg:seogoogle987】,IVQ
- https://www.nytimes.com/search?dropmab=true&query=谷歌maps群发程序|软件【tg:seogoogle987】,hgT
- https://www.lindseymedicalsupply.com/search/谷歌maps群发程序|软件【tg:seogoogle987】,zS3
- https://www.welshmountainzoo.org/shop/index.php?routeproduct/search&tag=谷歌maps群发程序|软件【tg:seogoogle987】,jfc
- https://www.paxnet.co.kr/search/jongmok?kwd=谷歌maps群发程序|软件【tg:seogoogle987】iUG
- https://www.zisha.com/shop/list.shtml?wap_keyword=谷歌maps群发程序|软件【tg:seogoogle987】,t0y
- https://www.rookwinkel.nl/catalogsearch/result/index/?q=谷歌maps群发程序|软件【tg:seogoogle987】,apa
- https://www.ntv.co.jp/3min/search/?action=QUERY&q=谷歌maps群发程序|软件【tg:seogoogle987】,YHY
- https://www.mygrandma.com/Items.aspx?search=谷歌maps群发程序|软件【tg:seogoogle987】,vFd
- https://www.world-architects.com/en/search?term=谷歌maps群发程序|软件【tg:seogoogle987】,7MP
- https://www.prattlibrary.org/search?q=谷歌maps群发程序|软件【tg:seogoogle987】,SdG
- https://www.pixiv.net/tags/谷歌maps群发程序|软件【tg:seogoogle987】,MJI
- https://xehay.vn/tim-kiem/=谷歌maps群发程序|软件【tg:seogoogle987】,U75
- https://www.dba.dk/soeg/?soeg=谷歌maps群发程序|软件【tg:seogoogle987】szU
- https://www.tiktok.com/tag/谷歌maps群发程序|软件【tg:seogoogle987】,vBx
- https://www.nbm.org/?action=QUERY&s=谷歌maps群发程序|软件【tg:seogoogle987】,II6
- https://www.sic-info.org/en/?s=谷歌maps群发程序|软件【tg:seogoogle987】,tj2
- https://www.lauben.com/en/?action=SEARCH&s=谷歌maps群发程序|软件【tg:seogoogle987】,HsC
- https://www.lifesciencesweden.se/search?q=谷歌maps群发程序|软件【tg:seogoogle987】,nKK
- https://www.zutari.com/search/谷歌maps群发程序|软件【tg:seogoogle987】,3cx
- https://www.teamlab.art/pt/?submit=谷歌maps群发程序|软件【tg:seogoogle987】,Fsx