Here is my configuration which worked for more than one year but suddenly stopped working.
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
stage: deploy
image: "hseeberger/scala-sbt:11.0.9.1_1.4.4_2.13.4"
before_script:
- apt-get update
- apt-get install sudo
- apt-get install apt-transport-https ca-certificates curl software-properties-common -y
- curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
- apt-get update
- apt-get install docker-ce -y
- sudo service docker start
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- sbt docker:publishLocal
The error in GitlabCI is the following:
[warn] [1] sbt-native-packager wasn't able to identify the docker version. Some features may not be enabled
[warn] sbt-native packager tries to parse the `docker version` output. This can fail if
[warn]
[warn] - the output has changed:
[warn] $ docker version --format '{{.Server.APIVersion}}'
[warn]
[warn] - no `docker` executable is available
[warn] $ which docker
[warn]
[warn] - you have not the required privileges to run `docker`
[warn]
[warn] You can display the parsed docker version in the sbt console with:
[warn]
[warn] sbt:your-project> show dockerApiVersion
[warn]
[warn] As a last resort you could hard code the docker version, but it's not recommended!!
[warn]
[warn] import com.typesafe.sbt.packager.docker.DockerApiVersion
[warn] dockerApiVersion := Some(DockerApiVersion(1, 40))
[warn]
[success] All package validations passed
[error] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[info] Removing intermediate image(s) (labeled "snp-multi-stage-id=9da90b0c-75e0-4f46-98eb-a17a1998a3b8")
[error] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[error] Something went wrong while removing multi-stage intermediate image(s)
[error] java.lang.RuntimeException: Nonzero exit value: 1
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:687)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$41(DockerPlugin.scala:266)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$41$adapted(DockerPlugin.scala:258)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] at sbt.Execute.work(Execute.scala:291)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] at java.base/java.lang.Thread.run(Thread.java:834)
[error] (Docker / publishLocal) Nonzero exit value: 1
I finally solved it by installing Sbt instead of Docker. I also use Docker in Docker service from Gitlab now that basically helps me avoid the problem above.
image: docker:19.03.12
services:
- mysql:latest
- docker:19.03.12-dind
docker:image:
needs: ["test"]
stage: deploy
before_script:
- apk update
- apk --no-cache add openjdk11
- export PATH="/usr/local/sbt/bin:$PATH"
- apk update && apk add bash ca-certificates wget tar && mkdir -p "/usr/local/sbt" && wget -qO - --no-check-certificate "https://github.com/sbt/sbt/releases/download/v1.5.5/sbt-1.5.5.tgz" | tar xz -C /usr/local/sbt --strip-components=1 && sbt sbtVersion
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- sbt docker:publishLocal
- docker tag x:latest registry.gitlab.com/x/y:0.1-SNAPSHOT-$(date +%Y-%m-%d-%H-%M)
- docker push registry.gitlab.com/x/y/project-$(date +%Y-%m-%d-%H-%M)
only:
- master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With