Issue supplying git credentials to docker alpine/git

1k Views Asked by At

I'm trying to create a docker image with multi-stage build:

  1. First stage pulls a private git repo
  2. Second stage builds that repo and runs a script

I have my git credentials stored in /Users/kabc/.config/git/credentials file on my host machine.

I'm mounting this in docker-compose like so:

  joke-generator:
    build:
      context: ./
      dockerfile: Dockerfile.joke-gen
    volumes:
      - ${HOME}/.config:/etc/.config:ro
      - ${HOME}/.gitconfig:/etc/.gitconfig:ro

Here's the dockerfile:

FROM alpine/git:2.36.3 as repository

WORKDIR /code

RUN git config --global credential.helper 'store --file /etc/.config/git/credentials'
RUN git -c http.sslVerify=false clone https://github.com/private-company/joke.git

FROM openjdk:19-jdk-alpine3.16

WORKDIR /code

COPY --from=repository /code/joke/ /code

RUN cd joke-generator
RUN mvn clean install -DskipTests

CMD ["./generate-joke.sh"]

But I'm getting this error in the git clone step:

fatal: could not read Username for 'https://github.com': No such device or address

Can I get some help with this please?

0

There are 0 best solutions below