docker中ubuntu部署 sbt

安装

使用官网教程中的方法

RUN echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
RUN sudo apt-get update
RUN sudo apt-get install sbt

初始化

sbt初始化和构建项目运行库时需要联网下载,但许多项目的生产环境中无法连接外网,两种解决方法。

1.在docker镜像生成时获取项目所需包文件
#进入build.sbt所在目录
WORKDIR XXX
RUN sbt compile
2.将sbt依赖和包的缓存文件直接移入docker的image中

sbt的依赖和缓存文件存储在用户目录的.ivy2和.sbt两个文件夹中,如root用户的/root/.ivy2    /root/.sbt

将这两个文件夹移入docker系统对应文件夹中。(当然前提是你在宿主机中已经build过此项目了)

其它注意事项

sbt使用的maven源默认使用https,且在国内没有服务器,因为墙的存在,所以下载非常之慢,这里安利下阿里云的源

想使用阿里源只需要在用户主目录  ~/.sbt/  文件夹下新建名为repositories文件,内容如下。

[repositories]
#local
public: http://maven.aliyun.com/nexus/content/groups/public/
typesafe:http://dl.bintray.com/typesafe/ivy-releases/ , [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
ivy-sbt-plugin:http://dl.bintray.com/sbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sonatype-oss-releases

sonatype-oss-snapshots

 

posted @ 2017-07-01 00:32  白杨春晓  阅读(550)  评论(0编辑  收藏  举报