I can’t seem to get a Quarkus project to build in GitLab. GL is running on a Docker stack, and it’s runners on the same Docker runtime.
I added a runner with the recommended configuration.
According to TestContainers:
This applies if you have your own GitlabCI runner installed, use the Docker executor and you have
/var/run/docker.sock
mounted in the runner configuration.
My runner config:
[[runners]]
name = "Docker Container"
url = "http://git.mydomain.com"
id = 16
token = "glrt-ASDFASDFADSFASD-Z"
token_obtained_at = 2024-05-24T22:41:53Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
tls_verify = false
image = "docker:latest"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
network_mtu = 0
And added TESTCONTAINERS_HOST_OVERRIDE
to my .gitlab-ci.yml
:
variables:
TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal"
Here is my .gitlab-ci.yml
, where I use a maven
image for the sage and manually install quarkus
before running the build:
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode --errors --update-snapshots"
MAVEN_OPTS: "-Daether.connector.https.securityMode=insecure"
TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal"
test:
stage: test
image:
name: maven:3.9.6-eclipse-temurin-21
services:
- name: redis
alias: redis
- name: docker:dind
alias: docker
command: ["--tls=false"]
variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
before_script:
- curl -Ls https://sh.jbang.dev | bash -s - trust add https://repo1.maven.org/maven2/io/quarkus/quarkus-cli/
- curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus@quarkusio
script:
- PATH=~/.jbang/bin:$PATH ./mvnw verify $MAVEN_CLI_OPTS -Dquarkus.redis.hosts=redis://redis -Dnative -Dquarkus.profile=dev -Dquarkus.container-image.build=true -Dquarkus.native.container-runtime=docker -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21
tags:
- quarkus
artifacts:
paths:
- target
expire_in: 1 week
only:
- master
- dev
- /^dev-[0-9]+(\.[0-9]+)+/
- /^master-[0-9]+(\.[0-9]+)+/
- tags
Error:
No container runtime was found. Make sure you have either Docker or Podman installed in your environment.
Full Error:
[INFO] --- quarkus:3.10.0:build (default) @ data-service ---
[WARNING] [io.quarkus.config] Unrecognized configuration key "quarkus.container-image.build" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
[WARNING] [io.quarkus.deployment.util.ContainerRuntimeUtil] quarkus.native.container-runtime config property must be set to either podman or docker and the executable must be available. Ignoring it.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.406 s
[INFO] Finished at: 2024-05-28T13:57:47Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.10.0:build (default) on project data-service: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#resolveNativeImageBuildRunner threw an exception: java.lang.IllegalStateException: No container runtime was found. Make sure you have either Docker or Podman installed in your environment.
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime(ContainerRuntimeUtil.java:58)
[ERROR] at io.quarkus.deployment.util.ContainerRuntimeUtil.detectContainerRuntime(ContainerRuntimeUtil.java:44)
[ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner.<init>(NativeImageBuildContainerRunner.java:31)
[ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildLocalContainerRunner.<init>(NativeImageBuildLocalContainerRunner.java:19)
[ERROR] at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.resolveNativeImageBuildRunner(NativeImageBuildStep.java:347)
[ERROR] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[ERROR] at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
[ERROR] at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[ERROR] at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
[ERROR] at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1495)
[ERROR] at java.base/java.lang.Thread.run(Thread.java:1583)
[ERROR] at org.jboss.threads.JBossThread.run(JBossThread.java:483)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
I make sure that docker
is available as a service, and override DOCKER_HOST
. None of that works, though. I even moved the service variable declarations to the root of the config, to no avail:
services:
- name: docker:dind
alias: docker
command: ["--tls=false"]
variables:
TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal"
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode --errors --update-snapshots -U"
MAVEN_OPTS: "-Daether.connector.https.securityMode=insecure"
test:
stage: test
image:
name: maven:3.9.6-eclipse-temurin-21
services:
- name: redis
alias: redis
before_script:
- curl -Ls https://sh.jbang.dev | bash -s - trust add https://repo1.maven.org/maven2/io/quarkus/quarkus-cli/
- curl -Ls https://sh.jbang.dev | bash -s - app install --fresh --force quarkus@quarkusio
script:
- PATH=~/.jbang/bin:$PATH ./mvnw verify -Dquarkus.redis.hosts=redis://redis -Dnative -Dquarkus.profile=dev -Dquarkus.container-image.build=true -Dquarkus.native.container-runtime=docker -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21
#-DskipTests -DskipIT
tags:
- quarkus
artifacts:
paths:
- target
expire_in: 1 week
only:
- master
- dev
- /^dev-[0-9]+(\.[0-9]+)+/
- /^master-[0-9]+(\.[0-9]+)+/
- tags
Same error.