Docker、sbt - 无法使用 centos docker 图像安装 sbt

Docker, sbt - cannot install sbt with centos docker image

我想在我的 docker 图片中加入 sbt。我根据 centos:centos8 图像创建了一个 Dockerfile

FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.18

RUN  yum install -y epel-release
RUN  yum update -y && yum install -y wget

RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar

WORKDIR /root
EXPOSE 8080

RUN sbt compile
CMD sbt run

而且我还需要在此处安装 sbt,但是当我 运行 这个脚本时出现错误:

Step 10/11 : RUN sbt compile
 ---> Running in 0aadcd774ba0
/bin/sh: sbt: command not found

我不明白为什么找不到 sbt。这是实现我需要的好方法还是我应该尝试其他方法?但是我需要用 centos

来做

编辑:

在下面的回答的帮助下,它终于可以工作了。工作脚本如下所示:

FROM centos:centos8
ENV SBT_VERSION 0.13.17

RUN yum install -y java-11-openjdk && \
    yum install -y epel-release && \
    yum update -y && yum install -y wget && \
    wget http://dl.bintray.com/sbt/rpm/sbt-$SBT_VERSION.rpm && \
    yum install -y sbt-$SBT_VERSION.rpm

WORKDIR /root
EXPOSE 8080

RUN sbt compile
CMD sbt run

您需要在 Dockerfile 中安装 sbt。这是一个例子:

FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.17

RUN yum install -y epel-release
RUN yum update -y && yum install -y wget

# INSTALL JAVA
RUN yum install -y java-11-openjdk

# INSTALL SBT
RUN wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
RUN yum install -y sbt-${SBT_VERSION}.rpm

RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar

WORKDIR /root
EXPOSE 8080

RUN sbt compile
CMD sbt run

注意:我在环境变量 (0.13.18) 中没有看到您的版本,所以我将其更改为 0.13.17。

我 运行 遇到 bintray.com 返回 403 运行domly 的问题。我假设这可能是某种交通堵塞。在本地添加了 rpm 文件。

COPY sbt-0.13.18.rpm /
RUN yum install -y sbt-0.13.18.rpm