I have the following logic in my GitLab-ci.yml:
stages:
- build
- deploy
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
make_patch:
image: node:10.19
stage: build
script:
- npm install
- make
- make source-package
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
artifacts:
when:
paths:
- test.tar.bz2
expire_in: 2 days
test_feature:
stage: deploy
image: dockerhub_image:123
script:
- apt-get install bzip2
- apt-get install curl -y
- ls -lah
- curl -kL https://mygitlabserver/namespace/project/-/jobs/artifacts/master/download?job=make_patch
- tar -xvjf test.tar.bz2
- docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
- docker build --no-cache -t $IMAGE_TAG .
- docker push $IMAGE_TAG
So I'm trying to test changes in my repo by building a nodejs image; if it compiles, then I save a zip file containing all the web files needed to be used in a potential production system. Then I download an existing image from public docker hub (cus this is actually an open source app we are modifying). I want to update the web folder there, and then try to create a docker container out of it and save it to my project repository. As you can see from the output below, it's currently failing because as @marvin pointed out, the dockerhub_image:123 in doesn't have the docker cli.
523$ docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
524/bin/bash: line 107: docker: command not found
525[cmd] sh exited 1
526[cont-finish.d] executing container finish scripts...
527[cont-finish.d] done.
528[s6-finish] waiting for services.
529[s6-finish] sending all processes the TERM signal.
530[s6-finish] sending all processes the KILL signal and exiting.
532ERROR: Job failed: exit code 1
I have defined a Deploy token in my project that looks like this:
Name: webtoken
Username: webtoken-1
Created: Aug 6, 2020
Expires: Never
Scopes
read_repository, read_registry, write_registry, read_package_registry, write_package_registry
I found this post: Gitlab CI - docker: command not found
But I'm having a hard time understanding where I would include the reference to the docker image in my case. Or could I just add a services clause within this "test_feature" job?
services:
- docker:dind
Sorry for the remedial questions. I'm just new to all things docker and GitLab. I tried changing the test_feature job like so, but it still fails with the same error:
test_feature:
stage: deploy
image: dockerhub_image:123
services:
- docker:dind
script:
- apt-get install bzip2
- apt-get install curl -y
- ls -lah
- curl -kL https://mygitlabserver/namespace/project/-/jobs/artifacts/master/download?job=make_patch
- tar -xvjf test.tar.bz2
- docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
- docker build --no-cache -t $IMAGE_TAG .
- docker push $IMAGE_TAG