Reputation: 31
THE PROBLEM
I have a git configuration that uses both access token and client certificates. While building docker image I need to use the same git configuration (in order to reach all required sources).
WHAT I DID for now is something like this in Dockerfile
and it works for me:
(...)
ARG SRC="/src"
RUN mkdir ${SRC}
# copying cert files inside docker image
COPY certificate.crt ${SRC}
COPY certificate.key ${SRC}
# configuring the same git settings inside
RUN git config --global user.name "${USER_NAME}"
RUN git config --global user.email "${EMAIL}"
RUN git config --global url."https://${ACCESS_TOKEN}@git_domain.com/".insteadOf "ssh://git@git_domain.com/"
RUN git config --global http."https://git_domain.com/".sslCert "/src/certificate.crt"
RUN git config --global http."https://git_domain.com/".sslKey "/src/certificate.key"
(...)
THE QUESTIONS ARE
Maybe is there some more "laconic" or simple way?
Is it possible to use existing local file .gitconfig
? Somehow to specify path to it?
I found this question Copying local git config into docker container, but docker run
doesn't fit. I need to do the similar thing, but using docker build
.
Upvotes: 3
Views: 3965
Reputation: 1324327
I need to do the similar thing, but using docker build.
I would generate the right gitconfig file locally first, then, once generated, COPY it from the Dockerfile, during a docker build
.
COPY .gitconfig .
Upvotes: 3