I want to include the repository in a Docker image. Or to express it differently I am using docker to build a docker image which should contain my repository
In the docker file I have the following lines:
## Copy us into the container COPY . /tmp/working ## Create the repository RUN git clone /tmp/working /repo # We need to prepare the branches otherwise cloning from them will fail WORKDIR /repo RUN \ # store the current branch CURRENT_BRANCH=`git branch | grep "^*" | sed 's/* //g' -` && \ # pull all remote references into our temporary repository git pull --all && \ # check out all branches so that they are available git branch -a | tail --lines=+3 | while read ref; do echo $ref | sed 's/remotes\/origin\///g' - | xargs git checkout; done && \ # checkout the branch we have been on git checkout $CURRENT_BRANCH && \ # debug the branches we have in the image git branch -a
When I build this image on my computer it works fine but when used during the CI process it fails since the process does perform a clone but leaves me with a detached head. I tried setting the stragey variable with no effect
build_image: stage: test image: docker:20-git variables: GIT_STRATEGY: clone services: - docker:18-dind tags: - docker script: - docker --version - docker build -f Dockerfile --build-arg CURRENT_BRANCH=$CI_COMMIT_BRANCH --build-arg GITDIR=$CI_PROJECT_DIR .
Any suggestions what I could do to get the full repository into the docker container building the image during the CI process?