I have a Gitlab pipeline that builds Docker containers using something similar to this template. Instead of logging in with username/password I want to use a Docker config.json
file to authenticate. I uploaded the config.json
to the secure files in the project. Now I’m trying to download the secure file following these procedures but since I’m using the docker:cli
image, there’s no curl
or bash
.
Here’s my code:
"build-docker-$[[ inputs.image ]]":
image: docker:cli
stage: publish
services:
- docker:dind
variables:
SECURE_FILES_DOWNLOAD_PATH: "./somepath/"
before_script:
- curl -s https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer | bash
- cp $SECURE_FILES_DOWNLOAD_PATH/dockerconfig.json ~/docker/config.json
- docker login $MY_REGISTRY
I get this error:
$ curl -s https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer | bash
/bin/sh: eval: line 154: curl: not found
/bin/sh: eval: line 154: bash: not found
If I use a basic job like in the example, it works:
test:
script:
- curl -s https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer | bash
- ls -lah .secure_files
So what’s the solution here? I can’t download the files with the docker:cli
image but that’s the job where I need to use the files. Is there a way to download them in a previous job and access them in the build-docker-
job?