skip to Main Content

Trying to execute integration tests using docker.

Below is the Dockerfile:

FROM openjdk:8u232

ARG SBT_VERSION=1.2.8

# Install sbt
RUN 
  curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && 
  dpkg -i sbt-$SBT_VERSION.deb && 
  rm sbt-$SBT_VERSION.deb && 
  apt-get update && 
  apt-get install sbt && 
  sbt sbtVersion

ENV WORK_DIR="/test"

USER root

COPY . ${WORK_DIR}/

RUN cd ${WORK_DIR}

RUN sbt clean it:test

Below is the docker-compose.yml:

version: '3.7'
services:
  test:
    build:
      context: ../..
      dockerfile: Dockerfile.test
    restart: always

when I run docker-compose -f test.yaml up :

it gives me error:

Step 10/10 : RUN sbt clean it:test
 ---> Running in d9513c01439b
[warn] No sbt.version set in project/build.properties, base directory: /
[info] Set current project to root (in build file:/)
[success] Total time: 0 s, completed Jun 6, 2020 7:20:37 AM
[error] Expected ';'
[error] No such setting/task
[error] it:test

to check it i removed this line from docker file and built the image and exec into container and my tests ran fine.

The structure of my project is:

src
  main
  it
  test

I tried executing the unit tests as well
but it gave me:

Step 10/10 : RUN sbt clean test
 ---> Running in c300fcf2bf53
[warn] No sbt.version set in project/build.properties, base directory: /
[info] Set current project to root (in build file:/)
[success] Total time: 0 s, completed Jun 6, 2020 7:19:13 AM

[success] Total time: 10 s, completed Jun 6, 2020 7:19:24 AM
Removing intermediate container c300fcf2bf53
 ---> c0215c62663d
Successfully built c0215c62663d
Successfully tagged it_it:latest
Creating it_it_1 ... done
Attaching to it_it_1

when i changed it to:

Step 10/10 : CMD sbt clean it:test
 ---> Running in 719b239fb7e4
Removing intermediate container 719b239fb7e4
 ---> f7adb19f2cb6

Successfully built f7adb19f2cb6
Successfully tagged it_it:latest
Creating it_it_1 ... done
Attaching to it_it_1
it_1     | [warn] No sbt.version set in project/build.properties, base directory: /
it_1     | [info] Set current project to root (in build file:/)
           [success] Total time: 0 s, completed Jun 6, 2020 7:32:24 AM
           [error] Expected ';'
it_1     | [error] No such setting/task
it_1     | [error] it:test
it_1     | [error]  

How can i execute sbt it:test from dockerfile using compose?

2

Answers


  1. Change to next:

    RUN cd ${WORK_DIR} && sbt clean it:test
    

    Different RUN in dockerfile won’t affect eachother.

    Login or Signup to reply.
  2. If it was working inside the container then this must work:

    ENTRYPOINT cd ${WORK_DIR} && 
                sbt clean it:test
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search