Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled

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 [email protected]:.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?

like image 746
Kingindanord Avatar asked Jun 28 '26 05:06

Kingindanord


1 Answers

As workaround, I clone the repo(s) manually and then edit go mod file

RUN git clone https://${USER}:${KEY}@gitlab.com/mygroup/myproject
RUN go mod init gitlab.com/mygroup/go-dns
RUN go mod edit -replace=gitlab.com/mygroup/myproject=./myproject
like image 177
Kingindanord Avatar answered Jun 29 '26 21:06

Kingindanord



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!