#Use Dagger SDKs in CI | Dagger

1 messages ยท Page 1 of 1 (latest)

wind stag
#

@rustic mango (started a proper thread)

Here is my current job

.docker:
  image: node:20-alpine
  services:
    - docker:${DOCKER_VERSION}-dind
  variables:
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_VERIFY: '1'
    DOCKER_TLS_CERTDIR: '/certs'
    DOCKER_CERT_PATH: '/certs/client'
    DOCKER_DRIVER: overlay2
    DOCKER_VERSION: '20.10.16'
.dagger:
  extends: [.docker]
  before_script:
    - apk add docker-cli curl
    - cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; }
dagger-build:
  extends: [.dagger]
  stage: build
  script:
    - docker info
    - which -a docker
    # - npm install -g @dagger.io/dagger
    - cd dagger
    - npm install
    - DOCKER_HOST=tcp://docker:2376 docker run hello-world
    # - DOCKER_HOST=tcp://docker:2376 node test.mjs
    - DOCKER_HOST=tcp://docker:2376 dagger run node dagger/test.mjs
rustic mango
#

Well.. the only difference I see with my example and your code is that I don't use the stage attribute in my build job. Not sure if that changes anything though ๐Ÿค”

wind stag
#

I copied the code that was in the example.
If I remove the DOCKER_HOST variable, then the docker info calls fails

#

That should just control when the job runs

#

... does dagger use the DOCKER_HOST to figure out how to connect to docker ?

rustic mango
wind stag
#

ya... thats what I figured... but then I get

$ DOCKER_HOST=tcp://docker:2376 dagger run node dagger/test.mjs
new client: failed to run container: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
: exit status 125
rustic mango
#

Are you using gitlab self hosted or something that could be different?

#

Strange that it works for my public repo in shared runners also

wind stag
#

no... we are using a hosted private repo

rustic mango
wind stag
#

Cool... I'll try that... Thanks for your help

wind stag
#

I just copied the main.py and the .gitlab-ci.yml and I'm getting the same issue with dagger trying to use the unix socket.
I'm going to try to add this job to one of my other repos and see how that behaves

#

I just tried it on another repo and it worked fine... so I don't know what is going on with that repo

wind stag
#

so it looks like the difference is that on the repo that doesn't work, it has the DAGGER_CLOUD_TOKEN variable defined

#

If I removed that from my 'normal' repo, then it successfully connects to docker

rustic mango
#

do you have that variable set to a valid token?

wind stag
#

Just saw this now... the token is valid, and I have the same one locally and it works.
I just added the token again, and it fails with the same error, but when I removed it, it worked

rustic mango