Docker setup for Scala/SBT, CircleCI 2.0

[SOLVED] Hi,

I am migrating pipelines from v1.0 to 2.0, using docker.

I have tried half a dozen different dockers providing Scala with SBT, and others seem statisfied with that, but whatever image I choose, I always get this output:

#!/bin/bash -eo pipefail
sbt sbtVersion

/bin/bash: sbt: command not found

I am trying to simply run “sbt sbtVersion”, which should print the version of SBT I have in my environment.

I literally copied different circleci configs from the web (e.g. https://hub.docker.com/r/codestar/circleci-scala-sbt-git/) but apparently it doesn’t work for me…

Here is my minified circle.yml. Can somebody please point out to me what the mistake is ?

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:6-browsers
      - image: codestar/circleci-scala-sbt-git:scala-2.12.2-sbt-0.13.15
    steps:
      - run:
          command: sbt sbtVersion

Nevermind, I searched for hours but I think I understood how it works 2 mins after posting this.
One cannot use multiple dockers to add content to the environment, only to deploy services. So I should create a custom docker image or install SBT manually inside the current environment.

@jdelafon I’m in a similar spot now setting up a Circle 2.0 Scala project. Do you have your circle.yml availably publicly somewhere by chance? Thanks :slight_smile:

@mecampbellsoup It is not public, but I copied below the circle.yml I ended up using for my tests.

My problem was that I thought one could load several services in the environment by specifying several docker images. It does not work like that: the docker container is a replacement for a (single) virtual machine. Either use an existing one, or create a custom Docker image with everything you need inside of it (maybe with a docker-compose, but I am not sure it creates a new image).

machine:
  #timezone: Europe/Zurich
  java:
    version: openjdk8
  services:
    - mysql


# Collect build artifacts
general:
  artifacts:
    - target/universal


dependencies:
  pre:
  #  - sbt about
  # Cache the resolution-cache and build streams to speed things up
  cache_directories:
    - "~/.sbt"
    - "target/resolution-cache"
    - "target/streams"
    - "project/target/resolution-cache"
    - "project/target/streams"
  # Compile all sources
  override:
    #- sbt update
    - sbt test:compile


database:
  override:
    - mysql -V
    - mysql -u ubuntu --execute "CREATE USER 'testuser'@'localhost';"
    - mysql -u ubuntu --execute "DROP DATABASE if exists uhtslimstest;"
    - mysql -u ubuntu --execute "CREATE DATABASE uhtslimstest;"
    - mysql -u ubuntu --execute "GRANT ALL PRIVILEGES ON uhtslimstest.* TO 'testuser'@'localhost';"

test:
  override:
    - sbt test:test
  # Copy test reports to Circle test reports dir then package app for deploy
  post:
    - mkdir -p $CIRCLE_TEST_REPORTS/junit/
    - find . -type f -regex ".*/target/test-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.