Skip to content

Instantly share code, notes, and snippets.

@brunojppb
Last active November 10, 2022 12:31
Show Gist options
  • Save brunojppb/2116ff2a4189ca7b3e3d3a6dab3fd4c4 to your computer and use it in GitHub Desktop.
Save brunojppb/2116ff2a4189ca7b3e3d3a6dab3fd4c4 to your computer and use it in GitHub Desktop.
Docker image with Java 8 and SBT 1.3.5

Docker image with Scala and SBT

This image is based on on alpine linux with Java 8 and includes SBT 1.3.5. You can optionally install Scala and make it available directly.

This is image is available here: brunojppb/scala-sbt:1.3.5

The Dockerfile.yml:

FROM openjdk:8-alpine
LABEL maintainer="[email protected]"

RUN apk update
RUN apk add postgresql-client

# Optional: Install Scala
# ENV SCALA_VERSION=2.12.8 \
# SCALA_HOME=/usr/share/scala
# NOTE: bash is used by scala/scalac scripts, and it cannot be easily replaced with ash.
# Optional Scala lang installed directly
# RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \
#    apk add --no-cache bash curl jq && \
#    cd "/tmp" && \
#    wget --no-verbose "https://downloads.typesafe.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" && \
#    tar xzf "scala-${SCALA_VERSION}.tgz" && \
#    mkdir "${SCALA_HOME}" && \
#    rm "/tmp/scala-${SCALA_VERSION}/bin/"*.bat && \
#    mv "/tmp/scala-${SCALA_VERSION}/bin" "/tmp/scala-${SCALA_VERSION}/lib" "${SCALA_HOME}" && \
#    ln -s "${SCALA_HOME}/bin/"* "/usr/bin/" && \
#    apk del .build-dependencies && \
#    rm -rf "/tmp/"*

RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates && apk add --no-cache bash curl jq

# Install SBT
RUN export PATH="/usr/local/sbt/bin:$PATH" \
    &&  apk update \
    && apk add ca-certificates wget tar && mkdir -p "/usr/local/sbt" \
    && wget -qO - --no-check-certificate "https://piccolo.link/sbt-1.3.5.tgz" | tar xz -C /usr/local/sbt --strip-components=1 \
    && sbt sbtVersion

# add sbt to path 
ENV PATH "/usr/local/sbt/bin:$PATH"

# now on your production image
# you can run `sbt stage` or `sbt dist` to generate your build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment