I am trying to build docker image for go app that is using different go packages from different private gitlab repos. When I was doing it on my local machine, I had to add the following commands in order to make it work;
git config --global url.git@gitlab.com:.insteadOf https://gitlab.com/
export GOPRIVATE=*gitlab*
In this case, my ssh key will be used and it worked fine.
Now, I want to do the same thing when building a Docker image but without using ssh keys so I though of using deployment token (the token has access for all repos in the gitlab group).
dockerfile:
FROM golang:1.14 AS builder
...
ARG USER
ARG KEY
RUN git config --global url."https://${USER}:${KEY}@gitlab.com/".insteadOf "https://gitlab.com/"
RUN export GOPRIVATE=*gitlab*
apparently, this didn't work and I become the following error:
Fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled
Can you please share your ideas on how I could make it work using deployment tokens?