FROM alpine as downloader

ARG SBT_VERSION=1.6.1

ARG REVISION
ARG BUILDTIME
LABEL REVISION=${REVISION}
LABEL BUILDTIME=${BUILDTIME}

RUN apk add tar
RUN wget -qO - https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz | tar zxf - -C /root

FROM public.ecr.aws/amazoncorretto/amazoncorretto:8

COPY --from=downloader /root/sbt /usr/local/sbt

RUN ln -s /usr/local/sbt/bin/sbt /usr/bin/sbt

# trigger donwloading all required dependencies
RUN sbt -Dsbt.rootdir=true sbtVersion

ENTRYPOINT ["sbt", "-Dsbt.rootdir=true"]
